Introduction¶
In the DSH “Everything is a Plugin” ecosystem, many extension capabilities are independently provided by community plugins. When the DSH Web GUI processes workspace files, it often needs to view directories directly within the interface, preview files, modify content, and check Git status before submitting.
folder-tree-sh is the workspace file tree plugin for the DSH Web GUI (dsh-ftree), providing file browsing, multi-format preview, inline editing, Git change panel, and complete file operations. It integrates into DSH Web via zero-core modification and hot-pluggable (profile bundle) methods.
What is this¶
The package name provided in the materials is folder-tree-sh, version 0.3.0 in package.json, and declares private: true. The license is MIT, and dsh.client.platform is web.
The repository address is:
https://github.com/Nothree-code/folder-tree-sh
Its positioning is the DSH Web GUI workspace file tree plugin: providing file tree, preview, edit, Git changes, and file operations capabilities on the web side.
Core Features¶
File Tree¶
The file tree sidebar supports:
- Directory expand / collapse.
- 5-second auto-refresh, manual refresh supported.
- Filter box: Real-time filtering by filename.
- Sort: Name / Size / Modified time, directories always on top.
- Hidden files toggle: Hides
.git/node_modules/.DS_Storeby default. - Width drag-and-drop adjustment, panel toggle state persisted to
localStorage.
Multi-tab Preview¶
The plugin supports multiple tabs to open multiple files simultaneously, with instant switching. Preview capabilities include:
- Markdown: Render + Edit dual mode, supports toolbar, live preview, auto-save,
Ctrl+S. - Workspace relative path images: e.g.,
, rendered via host raw route. - Code: 30+ languages lightweight highlighting.
- CSV: Automatic delimiter detection (
,;Tab), rendered as table. - Image: Supports zooming (
Ctrl+Scroll), double-click to reset. - PDF: Browser native rendering, uses
no-cachebyte stream. - DOCX: Relies on
mammothto convert to HTML for true rendering, including images; withoutmammoth, automatically degrades to PowerShell extracting plain text. - Text: Chunked loading, 1MB/chunk, 100MB limit; GBK encoding auto-detection and fallback.
Markdown Inline Editing¶
Markdown files support inline editing:
- Auto-save: 800ms debounce.
- Manual save:
Ctrl+S. - Scroll backup before save:
.dshbak.1to.dshbak.3.
Git Change Panel¶
The Git change panel provides:
- Branch display.
- Change list: Untracked / Staged / Modified.
- Operations:
- Stage:
add - Unstage:
restore --staged - Discard changes:
checkout --; untracked files go to recycle bin. - View diff:
diff/diff --cached
- Stage:
File Operations¶
The right-click menu supports the following file operations:
- Refresh.
- New file.
- New folder.
- Rename.
- Delete, goes to recycle bin, not permanently deleted.
- Copy / Cut / Paste.
- Copy in-place.
- Open source folder, i.e., locate in file explorer.
- Copy path.
- Add to chat, applicable to images.
Security Model¶
The plugin provides multiple boundary limits on the host side:
- Origin whitelist: Dynamically derived from
webStartup, e.g.,127.0.0.1,localhost,[::1], configured host,trustedHosts. Cross-site requests always return403. When listening on0.0.0.0(LAN), it degrades to relying solely on CSRF token. - Per-process anti-CSRF token: All change routes (
op/write/git-op) must carry a token issued by/dsh-ftree-token. - Workspace whitelist: All paths must be within registered workspace roots, deny by default.
- Delete to recycle bin: Not permanently deleted.
- Scroll backup before write:
.dshbak.1to.dshbak.3. - Shell injection protection: All PowerShell commands are escaped with single quotes,
'becomes''. realpathpath guard: All paths are normalized viarealpath, following symlinks and NTFS junctions, then checked against workspace prefix...traversal, junction, and symlink escape are all impossible to bypass the whitelist; non-existent write targets automatically backtrack to the nearest existing ancestor (realpathLenient).- Preview cache: Auto-invalidates based on file size verification, actively clears after write.
Installation and Enablement¶
Current materials do not provide official installation commands for end users. The README provides steps for development / local package installation scenarios.
First, sync modifications to node_modules entity copy:
powershell -ExecutionPolicy Bypass -File sync.ps1
If package.json has changes, e.g., name, version, dsh.client, execute local package installation / update:
cd ..\.. && pnpm add "file:./packages/dsh-ftree"
After the above steps, restart dsh web to take effect.
Typical Routes¶
The routes exposed on the host side are as follows:
GET /dsh-ftree-meta: Get version info.GET /dsh-ftree-token: Get CSRF token.GET /dsh-ftree-list: List directory, attaches modification time whenwithMtime=1.GET /dsh-ftree-read: Chunked read file, supportstext/image/pdf/docx.POST /dsh-ftree-op: Executerename/delete/paste/open/mkdir/newfile.POST /dsh-ftree-write: Save text, with.dshbakbackup.GET /dsh-ftree-pdf: Get PDF byte stream.GET /dsh-ftree-raw: Get workspace raw bytes, used for Markdown images and other scenarios.GET /dsh-ftree-git: Getgit status, including branch and changes.POST /dsh-ftree-git-op: Executestage/unstage/discard/diff.
Before calling change-related routes, you need to obtain the token issued by /dsh-ftree-token first.
Applicable Scenarios and Precautions¶
Suitable for these scenarios:
- Browse workspace directories in DSH Web GUI.
- Quickly preview Markdown, code, CSV, images, PDF, DOCX, text, and other files.
- Directly edit Markdown files and view backups before saving.
- View Git branch, change list before commit, and execute stage / unstage / discard / diff.
- Perform file operations like new, rename, delete, copy, move, etc.
Precautions before use:
- The plugin runs with the current
dshprocess permissions; source code and license should be checked before installation. - Current materials do not provide official installation commands for end users; installation commands cannot be simply constructed from the repository name.
- The plugin’s path capabilities are restricted by the workspace whitelist; paths must be located within registered workspace roots.
- DOCX true rendering relies on
mammoth; if missing, it degrades to PowerShell extracting plain text.
Links¶
- Directory page: Current materials do not include a verifiable directory page address.
- GitHub: https://github.com/Nothree-code/folder-tree-sh
- License: MIT