Metadata-Version: 2.5
Name: mdshelf
Version: 0.1.1
Summary: Browse a folder of Markdown files locally: sidebar, outline, highlights, margin comments, share and archive. No dependencies, works offline.
Author: Shamiq The Dev
License-Expression: MIT
License-File: LICENSE
License-File: licenses/inter-OFL.txt
License-File: licenses/jetbrains-mono-OFL.txt
License-File: licenses/marked-LICENSE.md
License-File: licenses/mermaid-LICENSE.txt
Keywords: docs,local,markdown,mermaid,viewer
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Documentation
Classifier: Topic :: Text Processing :: Markup :: Markdown
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# mdshelf

[![PyPI version](https://img.shields.io/pypi/v/mdshelf.svg)](https://pypi.org/project/mdshelf/)
[![Python 3.9+](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://pypi.org/project/mdshelf/)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
[![CI](https://github.com/ShamiqTheDev/mdshelf/actions/workflows/ci.yml/badge.svg)](https://github.com/ShamiqTheDev/mdshelf/actions/workflows/ci.yml)

View your AI planning docs and project docs as one browsable shelf. One command, nothing uploaded.

![mdshelf demo: browsing a project's Markdown, Mermaid diagrams, sidebar filter and highlights](docs/images/mdshelf-demo.gif)

## Why mdshelf

Planning and project context increasingly live in the repo itself: `CLAUDE.md`, `AGENTS.md`, plans, ADRs, specs, and scattered `docs/` markdown. Editors can open one file; there is still no easy way to read that material as one project shelf.

- **VS Code Markdown preview** is for the file you have open, not the whole tree as a docs site.
- **Obsidian** is a vault app with its own workspace and setup.
- **GitHub rendering** needs a remote and a browser tab per file; it is not a local review surface.

mdshelf is local, zero setup beyond install, and treats a folder of `.md` files as a small docs site.

## Install

```bash
pip install mdshelf
```

System-wide (isolated CLI):

```bash
pipx install mdshelf
```

Run without installing:

```bash
uvx mdshelf
```

Then:

```bash
mdshelf .
```

Opens http://127.0.0.1:8780/ (binds to localhost only). Python 3.9 or newer.

| Option | Meaning |
|---|---|
| `FOLDER` | folder to browse (default: current directory) |
| `-p, --port` | port on `127.0.0.1` (default `8780`) |
| `--no-open` | don't open a browser tab |
| `--title` | name in the sidebar (default: the folder's name) |
| `--archive-dir` | where Archive moves files, relative to `FOLDER` (default `archived`) |
| `--exclude DIR` | extra directory name to skip everywhere (repeatable) |
| `--read-only` | disable Archive/Restore so the server never changes a file |

`.git`, `node_modules`, `.venv`, `dist`, `build`, `vendor` and cache folders are always skipped.

## Features

- Sidebar of `.md` files with filter and collapsible folders (collapse fully, or drag the edge to resize)
- "On this page" outline that follows reading position
- Mermaid diagrams, tables, task lists, and code blocks with a copy button
- Highlights in four colours, listed in the outline panel
- Comments in the right margin, level with the text they refer to
- Share selected text (WhatsApp, Teams, Email) or copy as Slack / Markdown quote
- Light, dark, or automatic theme; adjustable text size and page width
- Archive / restore a doc with confirmation (moves it into an `archived/` folder and back)
- Only `.md` files under the folder you pass are listed; those docs plus common image types they link to are served on `127.0.0.1`

Python standard library only. The Markdown renderer, Mermaid and fonts ship inside the package so it works offline. Nothing is uploaded anywhere.

## Screenshots

**Your whole project's Markdown as one shelf**

![Your whole project's Markdown as one shelf](docs/images/ui-overview-dark.png)

**Agent instructions (CLAUDE.md) in the same shelf as your docs**

![Agent instructions (CLAUDE.md) in the same shelf as your docs](docs/images/ui-claude-md-dark.png)

**Specs with tables and Mermaid diagrams rendered**

![Specs with tables and Mermaid diagrams rendered](docs/images/ui-spec-mermaid-dark.png)

**Highlight and comment on a plan while you review it**

![Highlight and comment on a plan while you review it](docs/images/ui-plan-review-dark.png)

<details>
<summary>More screenshots</summary>

**Share a passage to Slack, Teams, WhatsApp, email or copy as Markdown**

![Share a passage to Slack, Teams, WhatsApp, email or copy as Markdown](docs/images/ui-share-popover-dark.png)

**Light theme**

![Light theme](docs/images/ui-overview-light.png)

</details>

## Keyboard shortcuts

| Key | Action |
|---|---|
| `/` | Focus the sidebar filter (opens the sidebar if it was collapsed) |
| `[` | Toggle the sidebar |
| `]` | Toggle the outline |

## Who it's for

Anyone reviewing AI planning docs and project markdown in a repo without standing up a docs site.

Package: [https://pypi.org/project/mdshelf/](https://pypi.org/project/mdshelf/)

Cursor `.mdc` rule files are not listed unless they are saved as `.md`.

## Where your notes live

Highlights and comments are saved **in your browser** (localStorage), per folder and per file, not in
your repo. They survive reloads and edits to the Markdown, because each one is stored as the quoted
text plus a little context rather than a position. If the quoted text is deleted, the note stays in the
list marked "not found" so you can remove it. Clearing site data or using another browser or machine
starts you with no notes. Archive and restore carry a file's notes along.

## Archive

Archive moves a doc to `<folder>/archived/<same path>` and Restore moves it back, refusing if something
already exists at the destination. If the folder is under git, add `archived/` to `.gitignore` to keep
archived files out of commits (git will show them as deleted). Use `--read-only` to turn this off.

## Security model

- Binds to `127.0.0.1` only. There is no option to listen on other interfaces.
- Serves `.md` files under the folder you pass, common image types linked from them (png, gif, jpg,
  webp, svg, …), plus its bundled assets. Paths that escape the folder, or point into skipped
  folders, are refused.
- The only write is Archive/Restore. It accepts requests only from its own page: the `Host` and `Origin`
  headers must be local and a custom header must be present, which blocks DNS-rebinding and cross-site
  requests.
- Share opens a link to the chosen service (WhatsApp, Teams, mail) with the selected text in the URL, only
  when you press the button. Slack and Markdown copy to the clipboard. Check what you select before sharing.
- Rendered Markdown is shown as HTML without sanitising, so only browse folders you trust.

## Develop

See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, tests, and how to open issues or pull requests.

The viewer is one HTML file, `src/mdshelf/static/index.html`, with no build step. Bundled third-party
files and licences are listed in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).

## Licence

MIT, see [LICENSE](LICENSE). Bundled fonts are under the SIL Open Font License 1.1; see `licenses/`.
