Metadata-Version: 2.4
Name: bunko
Version: 0.4.1
Summary: A read-only file server that renders Markdown, HTML, tables, Office files, images, and video in the browser
Author: Ivan Arevalo
License-Expression: MIT
Project-URL: Homepage, https://github.com/ivanfarevalo/bunko
Project-URL: Documentation, https://github.com/ivanfarevalo/bunko/tree/main/docs
Project-URL: Issues, https://github.com/ivanfarevalo/bunko/issues
Project-URL: Changelog, https://github.com/ivanfarevalo/bunko/blob/main/CHANGELOG.md
Keywords: http.server,file server,file browser,markdown,viewer,tailscale
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: System :: Filesystems
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.md
License-File: bunko/static/vendor/LICENSES/dompurify-apache-2.0.txt
License-File: bunko/static/vendor/LICENSES/dompurify-mpl-2.0.txt
License-File: bunko/static/vendor/LICENSES/highlight.js.txt
License-File: bunko/static/vendor/LICENSES/marked.txt
Dynamic: license-file

# Bunko

**A read-only file server that renders what it serves.** Point it at a folder
and open it in a browser: Markdown, HTML reports, Word documents, Excel
workbooks, CSV and JSONL tables, images, video, PDFs, code, and logs all open
in place, with the folder tree and search in a sidebar. It's a drop-in
replacement for `python -m http.server`, with no dependencies beyond Python.

*Bunko* (文庫) is Japanese for a small library, or a collection of books.

![A folder in Bunko](https://raw.githubusercontent.com/ivanfarevalo/bunko/main/docs/img/folder.png)

It's built for reading files where they live, usually on a remote machine:

- **Results and reports** from experiments, training runs, and pipelines:
  plots, tables, logs, videos, and HTML reports, without copying anything back.
- **Plans, notes, and reports written by AI coding agents** such as Claude Code.
  They render as they're written, and stay on your own machine.
- **A shared, read-only document folder** for a small team, with search and
  personal favorites and tags.

## Launch it

### 1. Install

Bunko needs Python 3.8 or later, and nothing else. Pick whichever fits:

```bash
uvx bunko                  # try it without installing anything (needs uv)
uv tool install bunko      # install the bunko command (or: pipx install bunko)
```

On a server without uv or pipx, this puts a single-file `bunko` in
`~/.local/bin`, using only Python and curl:

```bash
curl -fsSL https://github.com/ivanfarevalo/bunko/releases/latest/download/install.sh | sh
```

Or copy `bunko.pyz` from the [latest release](https://github.com/ivanfarevalo/bunko/releases/latest)
anywhere, and run it with `python3 bunko.pyz`.

### 2. Start it

```bash
bunko                  # serve the current folder on port 8000, or the next free one
bunko 8099 ~/reports   # choose the port and the folder
```

Bunko prints the address to open, then serves until you press `Ctrl+C`.

### 3. Open it

| Where Bunko runs | How to open it |
|---|---|
| Your own machine | Open the printed `http://localhost:8000/` |
| A remote machine, just for you | `bunko 8099 ~/reports` there, then `ssh -L 8099:localhost:8099 server` here, and open `http://localhost:8099/` |
| A remote machine, for named people on your tailnet (recommended) | See [Security](#security) below |
| A remote machine, behind a password-like token | `bunko 8099 ~/reports -b 0.0.0.0 --token`, then open the link it prints |

### 4. Keep it running (optional)

```bash
tmux new-session -d -s bunko 'bunko 8099 ~/reports'             # in tmux
bunko service install --name reports -- 8099 ~/reports          # as a systemd user service
```

[docs/deployment.md](https://github.com/ivanfarevalo/bunko/blob/main/docs/deployment.md) covers both, plus the optional tools
that add thumbnails (ffmpeg) and fast content search (ripgrep).

## Features

- **Recent files, favorites, and tags** pinned at the top of the sidebar, each
  tag with its own section. They're kept on the server, so they follow you
  between devices.
- **Folder tree and search.** Find files by name (`Ctrl+K`) or search inside
  them (`Ctrl+Shift+F`, with [ripgrep](https://github.com/BurntSushi/ripgrep)
  when installed). Content results open the file at the matching line.
- **Markdown.** GitHub-flavored, with highlighted code, working relative links
  and images, and an optional outline beside the page.
- **HTML pages** render with their own CSS, scripts, and relative assets, as
  under `http.server`.
- **Images and galleries,** with thumbnails generated by ffmpeg and cached.
- **Video with review tools:** frame stepping, exact frame numbers from
  ffprobe, speed control, and links to an exact moment (`?t=12.345`).
- **CSV, TSV, and JSONL tables.** Virtualized, sortable, filterable, and
  loaded in pieces, so large files open instantly.
- **Word and Excel.** `.docx` files open as pages, with headings, lists,
  tables, images, and footnotes. `.xlsx` sheets open as tables with Excel's
  row numbers and a tab per sheet. No Office or extra packages needed.
- **Code and logs** with highlighting and line numbers. Large files load in steps.
- **Live reload.** The open file refreshes when it changes on disk.
- **Documents, for people and AI agents.** `/bunko` in Claude Code or Codex
  writes up your work (a results report, a status update, an explainer, a
  proposal) as an HTML page in a consistent theme and folder layout, checks it,
  and hands you the link. Kinds, layouts, and themes are yours to change.
- **Links from the command line.** `bunko link report.html` prints the URL
  that opens it, so scripts and AI agents can hand you a clickable link.
- **Access control.** Tailscale identity (recommended) or an access token.
- **Runs anywhere:** foreground, tmux, or a systemd user service.

| | |
|---|---|
| ![Markdown with outline](https://raw.githubusercontent.com/ivanfarevalo/bunko/main/docs/img/outline.png) | ![A large CSV](https://raw.githubusercontent.com/ivanfarevalo/bunko/main/docs/img/table.png) |
| ![Video review tools](https://raw.githubusercontent.com/ivanfarevalo/bunko/main/docs/img/video.png) | ![Search inside files](https://raw.githubusercontent.com/ivanfarevalo/bunko/main/docs/img/content-search.png) |

## Security

Bunko never changes the folder it serves, hides dotfiles (including through
symlinks), and refuses path tricks. **By default it listens only on this
machine** (`127.0.0.1`). Reaching it from elsewhere is a choice you make:

| Setup | Who gets in | Transport |
|---|---|---|
| **Tailscale Serve + `--allow-user` (recommended)** | Named people, by Tailscale identity | HTTPS |
| The default + an SSH port forward | Whoever can SSH in | SSH |
| `-b <your Tailscale IP>` | Everyone on your tailnet | WireGuard |
| `-b 0.0.0.0 --token` | Anyone holding the token | Plain HTTP unless something adds HTTPS |
| `-b 0.0.0.0` | Anyone who can reach the port, as with `http.server` | Plain HTTP |

The recommended setup takes two commands:

```bash
bunko 8100 ~/reports --allow-user you@example.com
sudo tailscale serve --bg --https=8100 http://127.0.0.1:8100
# open https://<machine>.<tailnet>.ts.net:8100/
```

[docs/security.md](https://github.com/ivanfarevalo/bunko/blob/main/docs/security.md) explains each mode and its limits.

## Documentation

- [Features and shortcuts](https://github.com/ivanfarevalo/bunko/blob/main/docs/features.md)
- [Security and access control](https://github.com/ivanfarevalo/bunko/blob/main/docs/security.md)
- [Deployment: tmux, systemd, remote machines](https://github.com/ivanfarevalo/bunko/blob/main/docs/deployment.md)
- [Command-line reference](https://github.com/ivanfarevalo/bunko/blob/main/docs/cli.md)
- [Documents and the /bunko skill](https://github.com/ivanfarevalo/bunko/blob/main/docs/documents.md)
- [Development: environment, linters, tests, practices](https://github.com/ivanfarevalo/bunko/blob/main/docs/development.md)

The [project wiki](https://github.com/ivanfarevalo/bunko/blob/main/wiki/Home.md) tracks what Bunko is, where it's going, how
it's built, and what has been done so far, phase by phase.

## License

MIT. See [LICENSE](https://github.com/ivanfarevalo/bunko/blob/main/LICENSE). Bundled front-end libraries keep their own
licenses: [THIRD_PARTY_NOTICES.md](https://github.com/ivanfarevalo/bunko/blob/main/THIRD_PARTY_NOTICES.md).
