dirplot 0.1.2__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. {dirplot-0.1.2 → dirplot-0.3.0}/.claude/settings.local.json +2 -1
  2. dirplot-0.3.0/.dockerignore +11 -0
  3. {dirplot-0.1.2 → dirplot-0.3.0}/.github/workflows/ci.yml +19 -1
  4. dirplot-0.3.0/.ipynb_checkpoints/Untitled-checkpoint.ipynb +6 -0
  5. dirplot-0.3.0/CHANGELOG.md +120 -0
  6. dirplot-0.3.0/Dockerfile +21 -0
  7. dirplot-0.3.0/Makefile +41 -0
  8. dirplot-0.3.0/PKG-INFO +287 -0
  9. dirplot-0.3.0/README.md +241 -0
  10. dirplot-0.3.0/TASKS.md~ +25 -0
  11. dirplot-0.3.0/docs/ARCHIVES.md +117 -0
  12. dirplot-0.3.0/docs/EXAMPLES.md +385 -0
  13. dirplot-0.3.0/docs/SSH_DESIGN.md +395 -0
  14. dirplot-0.3.0/docs/docker.png +0 -0
  15. dirplot-0.3.0/docs/fastapi.png +0 -0
  16. dirplot-0.3.0/docs/flask.png +0 -0
  17. dirplot-0.3.0/docs/k8s.png +0 -0
  18. dirplot-0.3.0/docs/pypy.png +0 -0
  19. dirplot-0.3.0/docs/python.png +0 -0
  20. dirplot-0.3.0/docs/s3.png +0 -0
  21. {dirplot-0.1.2 → dirplot-0.3.0}/pyproject.toml +14 -3
  22. dirplot-0.3.0/scripts/make_docs_images.sh +16 -0
  23. dirplot-0.3.0/scripts/make_fixtures.py +144 -0
  24. dirplot-0.3.0/src/dirplot/__init__.py +17 -0
  25. dirplot-0.3.0/src/dirplot/archives.py +225 -0
  26. {dirplot-0.1.2 → dirplot-0.3.0}/src/dirplot/display.py +51 -31
  27. dirplot-0.3.0/src/dirplot/docker.py +252 -0
  28. dirplot-0.3.0/src/dirplot/github.py +192 -0
  29. dirplot-0.3.0/src/dirplot/k8s.py +272 -0
  30. dirplot-0.3.0/src/dirplot/main.py +344 -0
  31. {dirplot-0.1.2 → dirplot-0.3.0}/src/dirplot/render.py +4 -0
  32. dirplot-0.3.0/src/dirplot/s3.py +167 -0
  33. {dirplot-0.1.2 → dirplot-0.3.0}/src/dirplot/scanner.py +19 -3
  34. dirplot-0.3.0/src/dirplot/ssh.py +228 -0
  35. dirplot-0.3.0/src/dirplot/svg_render.py +561 -0
  36. dirplot-0.3.0/src/dirplot/terminal.py +42 -0
  37. dirplot-0.3.0/src.svg +370 -0
  38. dirplot-0.3.0/tests/conftest.py +132 -0
  39. dirplot-0.3.0/tests/fixtures/sample.7z +0 -0
  40. dirplot-0.3.0/tests/fixtures/sample.apk +0 -0
  41. dirplot-0.3.0/tests/fixtures/sample.ear +0 -0
  42. dirplot-0.3.0/tests/fixtures/sample.epub +0 -0
  43. dirplot-0.3.0/tests/fixtures/sample.jar +0 -0
  44. dirplot-0.3.0/tests/fixtures/sample.rar +0 -0
  45. dirplot-0.3.0/tests/fixtures/sample.tar +0 -0
  46. dirplot-0.3.0/tests/fixtures/sample.tar.bz2 +0 -0
  47. dirplot-0.3.0/tests/fixtures/sample.tar.gz +0 -0
  48. dirplot-0.3.0/tests/fixtures/sample.tar.xz +0 -0
  49. dirplot-0.3.0/tests/fixtures/sample.tbz2 +0 -0
  50. dirplot-0.3.0/tests/fixtures/sample.tgz +0 -0
  51. dirplot-0.3.0/tests/fixtures/sample.txz +0 -0
  52. dirplot-0.3.0/tests/fixtures/sample.war +0 -0
  53. dirplot-0.3.0/tests/fixtures/sample.whl +0 -0
  54. dirplot-0.3.0/tests/fixtures/sample.xpi +0 -0
  55. dirplot-0.3.0/tests/fixtures/sample.zip +0 -0
  56. dirplot-0.3.0/tests/test_archives.py +371 -0
  57. {dirplot-0.1.2 → dirplot-0.3.0}/tests/test_cli.py +20 -12
  58. {dirplot-0.1.2 → dirplot-0.3.0}/tests/test_display.py +36 -11
  59. dirplot-0.3.0/tests/test_docker.py +386 -0
  60. {dirplot-0.1.2 → dirplot-0.3.0}/tests/test_drawing.py +11 -7
  61. dirplot-0.3.0/tests/test_github.py +193 -0
  62. dirplot-0.3.0/tests/test_k8s.py +447 -0
  63. {dirplot-0.1.2 → dirplot-0.3.0}/tests/test_render.py +60 -0
  64. dirplot-0.3.0/tests/test_s3.py +186 -0
  65. {dirplot-0.1.2 → dirplot-0.3.0}/tests/test_scanner.py +10 -0
  66. dirplot-0.3.0/tests/test_ssh.py +319 -0
  67. dirplot-0.3.0/tests/test_svg_render.py +402 -0
  68. {dirplot-0.1.2 → dirplot-0.3.0}/tests/test_terminal.py +11 -0
  69. {dirplot-0.1.2 → dirplot-0.3.0}/uv.lock +865 -5
  70. dirplot-0.1.2/CHANGELOG.md +0 -35
  71. dirplot-0.1.2/Makefile +0 -38
  72. dirplot-0.1.2/PKG-INFO +0 -158
  73. dirplot-0.1.2/README.md +0 -121
  74. dirplot-0.1.2/src/dirplot/__init__.py +0 -3
  75. dirplot-0.1.2/src/dirplot/main.py +0 -153
  76. dirplot-0.1.2/src/dirplot/terminal.py +0 -28
  77. dirplot-0.1.2/tests/conftest.py +0 -30
  78. {dirplot-0.1.2 → dirplot-0.3.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  79. {dirplot-0.1.2 → dirplot-0.3.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  80. {dirplot-0.1.2 → dirplot-0.3.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  81. {dirplot-0.1.2 → dirplot-0.3.0}/.github/dependabot.yml +0 -0
  82. {dirplot-0.1.2 → dirplot-0.3.0}/.github/workflows/publish.yml +0 -0
  83. {dirplot-0.1.2 → dirplot-0.3.0}/.gitignore +0 -0
  84. {dirplot-0.1.2 → dirplot-0.3.0}/.pre-commit-config.yaml +0 -0
  85. {dirplot-0.1.2 → dirplot-0.3.0}/.python-version +0 -0
  86. {dirplot-0.1.2 → dirplot-0.3.0}/CONTRIBUTING.md +0 -0
  87. {dirplot-0.1.2 → dirplot-0.3.0}/LICENSE +0 -0
  88. {dirplot-0.1.2 → dirplot-0.3.0}/SECURITY.md +0 -0
  89. {dirplot-0.1.2 → dirplot-0.3.0}/docs/dirplot.png +0 -0
  90. {dirplot-0.1.2 → dirplot-0.3.0}/scripts/open_terminals.sh +0 -0
  91. {dirplot-0.1.2 → dirplot-0.3.0}/src/dirplot/__main__.py +0 -0
  92. {dirplot-0.1.2 → dirplot-0.3.0}/src/dirplot/colors.py +0 -0
  93. {dirplot-0.1.2 → dirplot-0.3.0}/src/dirplot/fonts/JetBrainsMono-Bold.ttf +0 -0
  94. {dirplot-0.1.2 → dirplot-0.3.0}/src/dirplot/fonts/JetBrainsMono-BoldItalic.ttf +0 -0
  95. {dirplot-0.1.2 → dirplot-0.3.0}/src/dirplot/fonts/JetBrainsMono-Italic.ttf +0 -0
  96. {dirplot-0.1.2 → dirplot-0.3.0}/src/dirplot/fonts/JetBrainsMono-Regular.ttf +0 -0
  97. {dirplot-0.1.2 → dirplot-0.3.0}/src/dirplot/fonts/OFL.txt +0 -0
  98. {dirplot-0.1.2 → dirplot-0.3.0}/src/dirplot/py.typed +0 -0
  99. {dirplot-0.1.2 → dirplot-0.3.0}/tests/__init__.py +0 -0
  100. {dirplot-0.1.2 → dirplot-0.3.0}/tests/example/bar/bar.py +0 -0
  101. {dirplot-0.1.2 → dirplot-0.3.0}/tests/example/bar/baz.json +0 -0
  102. {dirplot-0.1.2 → dirplot-0.3.0}/tests/example/foo/foo.md +0 -0
  103. {dirplot-0.1.2 → dirplot-0.3.0}/tests/test_colors.py +0 -0
@@ -6,7 +6,8 @@
6
6
  "Bash(uv pip:*)",
7
7
  "Bash(git mv:*)",
8
8
  "Bash(LC_ALL=C sed:*)",
9
- "Bash(find:*)"
9
+ "Bash(find:*)",
10
+ "Bash(docker run:*)"
10
11
  ]
11
12
  }
12
13
  }
@@ -0,0 +1,11 @@
1
+ .venv/
2
+ .git/
3
+ .pytest_cache/
4
+ __pycache__/
5
+ *.pyc
6
+ *.egg-info/
7
+ dist/
8
+ .mypy_cache/
9
+ .ruff_cache/
10
+ *.png
11
+ *.svg
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- python-version: ["3.10", "3.11", "3.12", "3.13"]
14
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
15
15
 
16
16
  steps:
17
17
  - uses: actions/checkout@v6
@@ -36,3 +36,21 @@ jobs:
36
36
 
37
37
  - name: Test
38
38
  run: uv run pytest --cov=src --cov-report=xml
39
+
40
+ test-windows:
41
+ runs-on: windows-latest
42
+
43
+ steps:
44
+ - uses: actions/checkout@v6
45
+
46
+ - name: Install uv
47
+ uses: astral-sh/setup-uv@v7
48
+
49
+ - name: Set up Python 3.10
50
+ run: uv python install 3.10
51
+
52
+ - name: Install dependencies
53
+ run: uv sync --all-extras
54
+
55
+ - name: Test
56
+ run: uv run pytest --cov=src --cov-report=xml
@@ -0,0 +1,6 @@
1
+ {
2
+ "cells": [],
3
+ "metadata": {},
4
+ "nbformat": 4,
5
+ "nbformat_minor": 5
6
+ }
@@ -0,0 +1,120 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.3.0] - 2026-03-10
11
+
12
+ ### Added
13
+
14
+ - Kubernetes pod scanning via `pod://pod-name/path` syntax — uses `kubectl exec` and
15
+ `find` to build the tree without copying files out of the pod. Works on any running
16
+ pod that has a POSIX shell and `find` (GNU or BusyBox). No extra dependency; only
17
+ `kubectl` is required.
18
+ - Namespace can be specified inline (`pod://pod-name@namespace:/path`) or via
19
+ `--k8s-namespace`.
20
+ - Container can be selected for multi-container pods via `--k8s-container`.
21
+ - `-xdev` is intentionally omitted so mounted volumes (emptyDir, PVC, etc.) within
22
+ the scanned path are traversed — the common case in k8s where images declare
23
+ `VOLUME` entries that are always mounted on a separate filesystem.
24
+ - Automatically falls back to a portable `sh` + `stat` loop on BusyBox/Alpine pods.
25
+ - `github://owner/repo[@branch]` URI scheme for GitHub repository scanning. The old
26
+ `github:owner/repo` shorthand has been removed.
27
+ - File tiles now have a 1-px dark outline (60/255 below fill colour per channel) so
28
+ adjacent same-coloured tiles — e.g. a directory full of extension-less files — are
29
+ always visually distinct rather than blending into a single flat block.
30
+
31
+ ### Changed
32
+
33
+ - `docs/REMOTE-ACCESS.md` renamed to `docs/EXAMPLES.md`; Docker and Kubernetes pod
34
+ sections added; images with captions added for all remote backends.
35
+
36
+ ### Fixed
37
+
38
+ - SVG tooltips now show the original byte count when `--log` is active, not the
39
+ log-transformed layout value. `Node.original_size` is populated by `apply_log_sizes`
40
+ for both file and directory nodes and is used by the SVG renderer for `data-size`.
41
+ - GitHub error messages are now clear and actionable:
42
+ - 401 explicitly says the token is invalid or expired.
43
+ - 403 distinguishes rate-limit exceeded (with the 60 vs 5,000 req/h figures and a
44
+ token hint) from a permissions failure on a private repository.
45
+ - 404 now also hints that a token is required for private repositories (GitHub returns
46
+ 404, not 403, for private repos accessed without authentication).
47
+ - Errors are caught in the CLI and printed as a single `Error: …` line to stderr
48
+ instead of showing a Python traceback.
49
+
50
+ ### Added
51
+
52
+ - Docker container scanning via `docker://container:/path` syntax — uses `docker exec`
53
+ and `find` to build the tree without copying files out of the container. Works on any
54
+ running container that has a POSIX shell and `find` (GNU or BusyBox). No extra
55
+ dependency; only the `docker` CLI is required.
56
+ - Automatically detects BusyBox `find` (Alpine-based images) and falls back to a
57
+ portable `sh` + `stat` loop when GNU `-printf` is unavailable.
58
+ - Virtual filesystems (`/proc`, `/sys`, `/dev`) are skipped via `-xdev`.
59
+ - Supports `--exclude`, `--depth`, `--log`, and all other standard options.
60
+ - `Dockerfile` and `.dockerignore` added so the project itself can be used as a
61
+ scan target.
62
+ - SVG output format via `--format svg` or by saving to a `.svg`-suffixed path with `--output`.
63
+ The output is a fully self-contained, interactive SVG file:
64
+ - **CSS hover highlight** — file tiles brighten and gain a soft glow; directory headers
65
+ brighten on mouse-over (`.tile` / `.dir-tile` classes, no JavaScript needed).
66
+ - **Floating tooltip panel** — a JavaScript-driven semi-transparent panel tracks the cursor
67
+ and shows the file or directory name, human-readable size, and file-type / item count.
68
+ No external scripts or stylesheets — the panel logic is embedded in the SVG itself.
69
+ - **Van Wijk cushion shading** — approximated via a single diagonal `linearGradient`
70
+ overlay (`gradientUnits="objectBoundingBox"`), defined once and shared across all tiles.
71
+ Matches the ×1.20 highlight / ×0.80 shadow range of the PNG renderer.
72
+ Disabled with `--no-cushion`.
73
+ - `--format png|svg` CLI option; format is also auto-detected from the `--output` file extension.
74
+ - `create_treemap_svg()` added to the public Python API (`from dirplot import create_treemap_svg`).
75
+ - `drawsvg>=2.4` added as a core dependency.
76
+ - Rename the treemap command to `map` (dirplot map <root>).
77
+ - Add `termsize` subcommand and restructure CLI as multi-command app.
78
+ - Add `--depht` parameter to limit the scanning of large file trees.
79
+ - Support for SSH remote directory scanning (`pip install dirplot[ssh]`).
80
+ - Support for AWS S3 buckets in the cloud (`pip install dirplot[s3]`).
81
+ - Support for local archive files, .zip, tgz, .tar.xz, .rar, .7z, etc.
82
+ - Include example archives for 17 different extentions for testing.
83
+ - Comprehensive documentation.
84
+
85
+ ## [0.2.0] - 2026-03-09
86
+
87
+ ### Added
88
+
89
+ - Support for Windows, incl. full test suite
90
+
91
+ ### Fixed
92
+
93
+ - Improved README, Makefile
94
+
95
+ ## [0.1.2] - 2026-03-06
96
+
97
+ ### Fixed
98
+
99
+ - Partly incorrect `uvx install dirplot` command
100
+ - Wrong version number in `uv.lock`
101
+
102
+ ## [0.1.1] - 2026-03-06
103
+
104
+ ### Fixed
105
+
106
+ - Typing complaints
107
+ - Improved README with better install/run commands
108
+
109
+ ## [0.1.0] - 2026-03-06
110
+
111
+ ### Added
112
+
113
+ - Nested squarified treemap rendered as a PNG at the exact pixel dimensions of the terminal window.
114
+ - Inline terminal display via iTerm2 and Kitty graphics protocols, auto-detected at runtime; supports iTerm2, WezTerm, Warp, Hyper, Kitty, and Ghostty.
115
+ - System-viewer fallback (`open` / `xdg-open`) as the default display mode.
116
+ - File-extension colours from the GitHub Linguist palette (~500 known extensions); unknown extensions fall back to a stable MD5-derived colour from the chosen colormap.
117
+ - Van Wijk quadratic cushion shading giving each tile a raised 3-D look (`--cushion`, on by default).
118
+ - Bundled JetBrains Mono fonts for crisp directory labels at any size.
119
+ - CLI options: `--output`, `--show/--no-show`, `--inline`, `--legend`, `--font-size`, `--colormap`, `--exclude`, `--size`, `--header/--no-header`, `--cushion/--no-cushion`, `--log`.
120
+ - Full test suite (65 tests), strict mypy, ruff linting, pre-commit hooks, and CI on Python 3.10–3.13.
@@ -0,0 +1,21 @@
1
+ FROM python:3.12-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install build tools needed by some optional deps
6
+ RUN pip install --no-cache-dir uv
7
+
8
+ # Copy project metadata first for layer caching
9
+ COPY pyproject.toml README.md ./
10
+
11
+ # Copy source
12
+ COPY src/ src/
13
+
14
+ # Install dirplot with all extras
15
+ RUN uv pip install --system --no-cache ".[ssh,s3,docker,dev]"
16
+
17
+ # Copy the rest (tests, docs, etc.) so the container is a useful scan target
18
+ COPY . .
19
+
20
+ # Keep the container running so docker:// scanning works
21
+ CMD ["sleep", "infinity"]
dirplot-0.3.0/Makefile ADDED
@@ -0,0 +1,41 @@
1
+ .PHONY: install lint format test coverage clean install-tool check-all publish-test publish help
2
+
3
+ help: ## Show this help
4
+ @grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*## "}; {printf " %-14s %s\n", $$1, $$2}'
5
+
6
+ install: ## Install all dependencies (including extras)
7
+ uv sync --all-extras
8
+
9
+ format: ## Auto-format and fix lint issues
10
+ uv run ruff format src tests
11
+ uv run ruff check --fix src tests
12
+
13
+ lint: ## Run ruff and mypy
14
+ uv run ruff check src tests
15
+ uv run --all-extras mypy src
16
+
17
+ test: ## Run the test suite
18
+ uv run --all-extras pytest
19
+
20
+ coverage: ## Run tests with HTML + terminal coverage report
21
+ uv run --all-extras pytest --cov=src --cov-report=html --cov-report=term
22
+
23
+ check-all: install format lint test clean ## Run format, lint, test, and clean
24
+ @echo "All checks passed!"
25
+
26
+ install-tool: ## Install dirplot as a uv tool (reinstall)
27
+ uv tool install --reinstall .
28
+
29
+ clean: ## Remove build artifacts and caches
30
+ rm -rf dist build *.egg-info
31
+ rm -rf .pytest_cache .mypy_cache .ruff_cache
32
+ rm -rf htmlcov .coverage coverage.xml
33
+ find . -type d -name __pycache__ -exec rm -rf {} +
34
+
35
+ publish-test: ## Build and publish to TestPyPI
36
+ uv build
37
+ uv publish --index testpypi --token $(TEST_PYPI_TOKEN)
38
+
39
+ publish: ## Build and publish to PyPI
40
+ uv build
41
+ uv publish --token $(PYPI_TOKEN)
dirplot-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,287 @@
1
+ Metadata-Version: 2.4
2
+ Name: dirplot
3
+ Version: 0.3.0
4
+ Summary: Static treemap bitmaps for directory trees and archives, displayed as inline terminal images
5
+ Project-URL: Repository, https://github.com/deeplook/dirplot
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: System Administrators
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Scientific/Engineering :: Visualization
22
+ Classifier: Topic :: System :: Archiving
23
+ Classifier: Topic :: System :: Filesystems
24
+ Classifier: Topic :: Terminals
25
+ Classifier: Topic :: Utilities
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.10
28
+ Requires-Dist: drawsvg>=2.4.1
29
+ Requires-Dist: matplotlib>=3.7
30
+ Requires-Dist: pillow>=9.0
31
+ Requires-Dist: py7zr>=0.20
32
+ Requires-Dist: rarfile>=4.0
33
+ Requires-Dist: squarify>=0.4
34
+ Requires-Dist: typer>=0.9
35
+ Provides-Extra: dev
36
+ Requires-Dist: mypy>=1.10; extra == 'dev'
37
+ Requires-Dist: pre-commit>=3.0; extra == 'dev'
38
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
39
+ Requires-Dist: pytest>=8.0; extra == 'dev'
40
+ Requires-Dist: ruff>=0.4; extra == 'dev'
41
+ Provides-Extra: s3
42
+ Requires-Dist: boto3>=1.26; extra == 's3'
43
+ Provides-Extra: ssh
44
+ Requires-Dist: paramiko>=3.0; extra == 'ssh'
45
+ Description-Content-Type: text/markdown
46
+
47
+ # dirplot
48
+
49
+ [![CI](https://github.com/deeplook/dirplot/actions/workflows/ci.yml/badge.svg)](https://github.com/deeplook/dirplot/actions/workflows/ci.yml)
50
+ [![PyPI](https://img.shields.io/pypi/v/dirplot.svg)](https://pypi.org/project/dirplot/)
51
+ [![Python](https://img.shields.io/pypi/pyversions/dirplot.svg)](https://pypi.org/project/dirplot/)
52
+ [![Downloads](https://img.shields.io/pypi/dm/dirplot.svg)](https://pepy.tech/project/dirplot)
53
+ [![License](https://img.shields.io/pypi/l/dirplot.svg)](https://pypi.org/project/dirplot/)
54
+ [![Buy Me a Coffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=flat&logo=buy-me-a-coffee&logoColor=black)](https://www.buymeacoffee.com/deeplook)
55
+
56
+ **dirplot** creates static nested treemap images for directory trees. It can display them in the system image viewer (default, works everywhere) or inline inside the terminal using the [iTerm2 inline image protocol](https://iterm2.com/documentation-images.html) or the [Kitty graphics protocol](https://sw.kovidgoyal.net/kitty/graphics-protocol/) — detected automatically at runtime.
57
+
58
+ ![dirplot output](https://raw.githubusercontent.com/deeplook/dirplot/main/docs/dirplot.png)
59
+
60
+ ## Features
61
+
62
+ - Directories are shown as labelled, nested containers, mirroring the actual hierarchy.
63
+ - Squarified treemap layout — rectangles are as square as possible for easy reading.
64
+ - File area proportional to file size; colour determined by file extension.
65
+ - ~500 known extensions mapped to colours from the [GitHub Linguist](https://github.com/github/linguist) table; unknown extensions get an MD5-stable colour from any Matplotlib colormap.
66
+ - Label colour (black/white) chosen automatically based on background luminance.
67
+ - Output resolution matches the current terminal window pixel size (via `TIOCGWINSZ`), or a custom `WIDTHxHEIGHT`.
68
+ - Van Wijk cushion shading gives tiles a raised 3-D appearance (optional).
69
+ - **SVG output** (`--format svg` or `--output file.svg`) produces a fully self-contained interactive file: CSS hover highlight, a JavaScript floating tooltip panel, and cushion shading via a gradient — no external dependencies.
70
+ - Display via system image viewer or inline in the terminal (iTerm2 and Kitty protocols, auto-detected).
71
+ - Save output to a PNG or SVG file with `--output`.
72
+ - Exclude paths with `--exclude` (repeatable).
73
+ - Works on macOS, Linux, and Windows; WSL2 fully supported.
74
+ - Scan remote hosts over SSH (`pip install "dirplot[ssh]"`), AWS S3 buckets (`pip install "dirplot[s3]"`), any public/private GitHub repository, **running Docker containers**, or **Kubernetes pods** — all without extra dependencies beyond the respective CLI/SDK. See [EXAMPLES.md](docs/EXAMPLES.md).
75
+
76
+ ## How It Works
77
+
78
+ 1. Scans the directory tree, collecting each file's path, extension, and size in bytes.
79
+ 2. Computes a squarified dirplot layout recursively — directories allocate space for their children.
80
+ 3. Renders to a PNG via Pillow (PIL) at the exact pixel dimensions of the current terminal window (detected via `TIOCGWINSZ`), or at a custom size when `--size` is given.
81
+ 4. Displays via the system image viewer (`open` / `xdg-open`) or inline via an auto-detected terminal graphics protocol (iTerm2 or Kitty).
82
+
83
+ Extension colours come from the [GitHub Linguist](https://github.com/github/linguist) language colour table (~500 known extensions). Unknown extensions fall back to an MD5-stable colour derived from the chosen `--colormap`. File label text is automatically black or white depending on the background luminance.
84
+
85
+ ## Installation
86
+
87
+ > **Note:** The recommended install methods below use [uv](https://docs.astral.sh/uv/). See the [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/) if you don't have it yet. Alternatively, use `pip install dirplot` to install without uv.
88
+
89
+ ```bash
90
+ # As a standalone tool (recommended)
91
+ uv tool install dirplot
92
+
93
+ # Into the current environment
94
+ pip install dirplot
95
+ ```
96
+
97
+ ### From GitHub
98
+
99
+ ```bash
100
+ # As a standalone tool
101
+ uv tool install git+https://github.com/deeplook/dirplot
102
+
103
+ # Into the current environment
104
+ pip install git+https://github.com/deeplook/dirplot
105
+ ```
106
+
107
+ ## Platform Support
108
+
109
+ This tool has been developed and tested on macOS and is CI-tested on Linux and Windows (Python 3.10+). The default `--show` mode works on all platforms. The `--inline` mode requires a terminal emulator that supports the iTerm2 or Kitty graphics protocol; on Windows, only [WezTerm](https://wezfurlong.org/wezterm/) currently qualifies. WSL2 is treated as Linux and has full support. Feedback and bug reports are welcome — please open an issue on GitHub.
110
+
111
+ ## Usage
112
+
113
+ ```bash
114
+ # Use it before installing it
115
+ uvx dirplot --help
116
+
117
+ # Show dirplot for the current directory (opens image in system viewer)
118
+ dirplot map .
119
+
120
+ # Show current terminal size in characters and pixels
121
+ dirplot termsize
122
+
123
+ # Save to a file without displaying
124
+ dirplot map . --output dirplot.png --no-show
125
+
126
+ # Display inline (protocol auto-detected: iTerm2, Kitty, Ghostty)
127
+ dirplot map . --inline
128
+
129
+ # Exclude directories
130
+ dirplot map . --exclude .venv --exclude .git
131
+
132
+ # Use a different colormap and larger directory labels
133
+ dirplot map . --colormap Set2 --font-size 18
134
+
135
+ # Render at a fixed resolution instead of terminal size
136
+ dirplot map . --size 1920x1080 --output dirplot.png --no-show
137
+
138
+ # Don't apply cushion shading — makes tiles look flat
139
+ dirplot map . --no-cushion
140
+
141
+ # Save as an interactive SVG (hover highlight + floating tooltip)
142
+ dirplot map . --output treemap.svg --no-show
143
+
144
+ # Force SVG format explicitly
145
+ dirplot map . --format svg --output treemap.svg --no-show
146
+ ```
147
+
148
+ ### Options
149
+
150
+ | Flag | Short | Default | Description |
151
+ |---|---|---|---|
152
+ | `--output` | `-o` | — | Save to this path (PNG or SVG) |
153
+ | `--format` | `-f` | auto | Output format: `png` or `svg`. Auto-detected from `--output` extension |
154
+ | `--show/--no-show` | | `--show` | Display the image after rendering |
155
+ | `--inline` | | off | Display in terminal (protocol auto-detected; PNG only) |
156
+ | `--legend/--no-legend` | | `--no-legend` | Show file-extension colour legend |
157
+ | `--font-size` | `-s` | `12` | Directory label font size in pixels |
158
+ | `--colormap` | `-c` | `tab20` | Matplotlib colormap for unknown extensions |
159
+ | `--exclude` | `-e` | — | Path to exclude (repeatable) |
160
+ | `--size` | | terminal size | Output dimensions as `WIDTHxHEIGHT` (e.g. `1920x1080`) |
161
+ | `--header/--no-header` | | `--header` | Print info lines before rendering |
162
+ | `--cushion/--no-cushion` | | `--cushion` | Apply van Wijk cushion shading for a raised 3-D look |
163
+ | `--log/--no-log` | | `--no-log` | Use log of file sizes for layout, making small files more visible |
164
+ | `--github-token` | | `$GITHUB_TOKEN` | GitHub personal access token for private repos or higher rate limits |
165
+
166
+ ## Inline Display
167
+
168
+ The `--inline` flag renders the image directly in the terminal. The protocol is auto-detected at runtime: terminals that support the [Kitty graphics protocol](https://sw.kovidgoyal.net/kitty/graphics-protocol/) use APC chunks (`ESC_G…`); all others fall back to the [iTerm2 inline image protocol](https://iterm2.com/documentation-images.html) (`ESC]1337;File=…`).
169
+
170
+ | Terminal | Platform | Protocol |
171
+ |---|---|---|
172
+ | [iTerm2](https://iterm2.com/) | macOS | iTerm2 |
173
+ | [WezTerm](https://wezfurlong.org/wezterm/) | macOS, Linux, Windows | Kitty & iTerm2 |
174
+ | [Warp](https://www.warp.dev/) | macOS, Linux | iTerm2 |
175
+ | [Hyper](https://hyper.is/) | macOS, Linux, Windows | iTerm2 |
176
+ | [Kitty](https://sw.kovidgoyal.net/kitty/) | macOS, Linux | Kitty |
177
+ | [Ghostty](https://ghostty.org/) | macOS, Linux | Kitty |
178
+
179
+ The default mode (`--show`, no `--inline`) opens the PNG in the system viewer (`open` on macOS, `xdg-open` on Linux, system default on Windows) and works in any terminal.
180
+
181
+ > **Windows note:** Common Windows shells (PowerShell, cmd, Git Bash) and terminal emulators (Windows Terminal, ConEmu) do not support any inline image protocol. `--inline` will silently produce no output in these environments. [WezTerm](https://wezfurlong.org/wezterm/) is currently the only mainstream Windows terminal emulator that supports inline image rendering (via the Kitty graphics protocol). WSL2 is treated as Linux and has full support.
182
+
183
+ > **Tip:** In terminals that support inline images (iTerm2, WezTerm, Kitty, etc.), the rendered image can often be dragged directly out of the terminal window and dropped into another application or saved to the desktop — no `--output` needed. This drag-and-drop behaviour is not guaranteed across all terminals.
184
+
185
+ > **Note:** `--inline` does not work in AI coding assistants such as Claude Code, Cursor, or GitHub Copilot Chat. These tools intercept terminal output as plain text and do not implement any graphics protocol, so the escape sequences are either stripped or displayed as garbage. Use the default `--show` mode (system viewer) or `--output` to save the PNG to a file instead. Or use [Pi](https://pi.dev) where it is easily added as an extension.
186
+
187
+ ## Archives
188
+
189
+ dirplot can read local archive files (zip, tar, 7z, rar, and ZIP-based formats like jar, whl, apk) as treemap inputs without unpacking them. See [ARCHIVES.md](docs/ARCHIVES.md) for supported formats, dependencies, and RAR setup on macOS.
190
+
191
+ ```bash
192
+ dirplot map project.zip
193
+ dirplot map release.tar.gz --depth 2
194
+ dirplot map app.jar
195
+ ```
196
+
197
+ ## Remote Access
198
+
199
+ dirplot can scan SSH hosts, AWS S3 buckets, GitHub repositories, running Docker containers, and Kubernetes pods. See [EXAMPLES.md](docs/EXAMPLES.md) for full details.
200
+
201
+ ```bash
202
+ pip install "dirplot[ssh]" # SSH via paramiko
203
+ pip install "dirplot[s3]" # AWS S3 via boto3
204
+ # GitHub: no extra dependency needed
205
+ # Docker: only the docker CLI required
206
+ # Kubernetes: only kubectl required
207
+ ```
208
+
209
+ ```bash
210
+ dirplot map ssh://alice@prod.example.com/var/www
211
+ dirplot map s3://noaa-ghcn-pds --no-sign
212
+ dirplot map github://pallets/flask
213
+ dirplot map docker://my-container:/app
214
+ dirplot map pod://my-pod:/app
215
+ dirplot map pod://my-pod@staging:/app
216
+ ```
217
+
218
+ ### GitHub authentication
219
+
220
+ Public repositories work without a token but are subject to GitHub's unauthenticated rate limit of **60 requests/hour**. A personal access token raises this to **5,000 requests/hour** and is required for private repositories.
221
+
222
+ Pass a token via the `--github-token` flag or the `GITHUB_TOKEN` environment variable:
223
+
224
+ ```bash
225
+ # via flag
226
+ dirplot map github://my-org/private-repo --github-token ghp_…
227
+
228
+ # via environment variable (also picked up automatically by the CLI)
229
+ export GITHUB_TOKEN=ghp_…
230
+ dirplot map github://my-org/private-repo
231
+ ```
232
+
233
+ To create a token: GitHub → Settings → Developer settings → Personal access tokens → Generate new token (see [GitHub's guide](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)). For read-only treemap access the `public_repo` scope (or no scope for public repos) is sufficient; add `repo` for private repositories.
234
+
235
+ ## Python API
236
+
237
+ The public API is small — `build_tree`, `create_treemap`, `create_treemap_svg`, and the display helpers:
238
+
239
+ ```python
240
+ from pathlib import Path
241
+ from dirplot import build_tree, create_treemap, create_treemap_svg
242
+
243
+ root = build_tree(Path("/path/to/project"))
244
+
245
+ # PNG — returns a BytesIO containing PNG bytes
246
+ buf = create_treemap(root, width_px=1920, height_px=1080, colormap="tab20", cushion=True)
247
+ Path("treemap.png").write_bytes(buf.read())
248
+
249
+ # SVG — returns a BytesIO containing UTF-8 SVG bytes
250
+ # Includes CSS hover highlight, a JS floating tooltip, and cushion gradient shading.
251
+ buf = create_treemap_svg(root, width_px=1920, height_px=1080, cushion=True)
252
+ Path("treemap.svg").write_bytes(buf.read())
253
+ ```
254
+
255
+ To open a PNG in the system image viewer or display it inline in the terminal:
256
+
257
+ ```python
258
+ from dirplot.display import display_window, display_inline
259
+
260
+ buf.seek(0)
261
+ display_window(buf) # system viewer (works everywhere)
262
+
263
+ buf.seek(0)
264
+ display_inline(buf) # inline in terminal (iTerm2 / Kitty / WezTerm)
265
+ ```
266
+
267
+ In a Jupyter notebook, PNG output renders automatically via PIL:
268
+
269
+ ```python
270
+ from PIL import Image
271
+ buf = create_treemap(root, width_px=1280, height_px=720)
272
+ Image.open(buf) # Jupyter renders PIL images automatically via _repr_png_()
273
+ ```
274
+
275
+ ## Development
276
+
277
+ ```bash
278
+ git clone https://github.com/deeplook/dirplot
279
+ cd dirplot
280
+ make test
281
+ ```
282
+
283
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for full details.
284
+
285
+ ## License
286
+
287
+ [MIT](LICENSE)