Skip to content

Commit 0b5dfe2

Browse files
committed
fix(lint): resolve all ruff and mypy errors
- Fix B023: lambda capturing loop var `ratio` in make_fade_out_frames (use default arg) - Fix mypy [assignment]: rename local `dark` → `border` in render_png.py and svg_render.py to avoid shadowing bool param - Fix mypy [arg-type]: resolve `int | None` fade_out_frames before passing to make_fade_out_frames in replay_cmd - Remove now-unnecessary type: ignore comments in render_png.py
1 parent 2fde6d9 commit 0b5dfe2

9 files changed

Lines changed: 483 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
## [0.4.1] - 2026-xx-xx
10+
## [0.4.1] - 2026-04-03
1111

1212
### Added
1313

14-
- **Automatic `gh` CLI credential fallback** — if `--github-token` and `GITHUB_TOKEN`
15-
are both absent, dirplot silently runs `gh auth token`. Users authenticated with the
16-
[GitHub CLI](https://cli.github.com/) (`gh auth login`) can access private repositories
17-
with no extra configuration. Token resolution order: `--github-token`
18-
`$GITHUB_TOKEN``gh auth token`.
1914
- **`--last PERIOD`** for `dirplot git` — filter commits by a relative time period instead
2015
of (or in addition to) `--max-commits`. Accepts a number followed by a unit:
2116
`m` (minutes), `h` (hours), `d` (days), `w` (weeks), `mo` (months = 30 days).
@@ -27,6 +22,58 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2722
dirplot git github://owner/repo -o history.mp4 --animate --last 2w --max-commits 10
2823
```
2924

25+
- **`dirplot demo` command** — new subcommand that runs a curated set of example commands
26+
and saves outputs to a folder. Useful for first-time walkthroughs or verifying that
27+
everything works in a given environment. Accepts `--output` (default: `demo/`),
28+
`--github-url` (default: `https://github.com/deeplook/dirplot`), and
29+
`--interactive` / `-i` to step through and confirm each command individually. Output
30+
uses rich formatting with colour, section rules, and status indicators.
31+
```bash
32+
dirplot demo # run all examples, save to ./demo/
33+
dirplot demo --output ~/dp-demo --interactive
34+
```
35+
36+
- **`--fade-out` for animated output** — appends a fade-out sequence at the end of
37+
animations produced by `dirplot git --animate`, `dirplot watch --animate`, and
38+
`dirplot replay`. Four flags control the effect:
39+
- `--fade-out` / `--no-fade-out` — enable/disable (default: off)
40+
- `--fade-out-duration SECS` — total fade length in seconds (default: 1.0)
41+
- `--fade-out-frames N` — number of blend steps; defaults to 4 per second of duration
42+
so longer fades are automatically finer-grained
43+
- `--fade-out-color COLOR` — target colour: `auto` (black in dark mode, white in light
44+
mode), `transparent` (PNG/APNG only; fades to fully transparent), any CSS colour
45+
name, or hex code (e.g. `"#1a1a2e"`)
46+
```bash
47+
dirplot git . -o history.png --animate --fade-out
48+
dirplot git . -o history.mp4 --animate --fade-out --fade-out-duration 2.0
49+
dirplot git . -o history.png --animate --fade-out --fade-out-color transparent
50+
```
51+
52+
- **`--dark` / `--light` mode** for all treemap commands — controls background and border
53+
colours. Dark mode (default) uses a near-black canvas with white directory labels; light
54+
mode uses a white canvas with black labels. Available on `map`, `git`, `watch`, and
55+
`replay`.
56+
```bash
57+
dirplot map . --light
58+
dirplot git . -o history.mp4 --animate --light
59+
```
60+
61+
- **Metadata in MP4/MOV output**`dirplot git`, `dirplot watch`, and `dirplot replay`
62+
now embed the same dirplot metadata (date, software version, OS, Python version,
63+
executed command) into MP4/MOV files that was previously only written to PNG and SVG.
64+
`dirplot read-meta` reads it back via `ffprobe`.
65+
66+
- **Automatic `gh` CLI credential fallback** — if `--github-token` and `GITHUB_TOKEN`
67+
are both absent, dirplot silently runs `gh auth token`. Users authenticated with the
68+
[GitHub CLI](https://cli.github.com/) (`gh auth login`) can access private repositories
69+
with no extra configuration. Token resolution order: `--github-token`
70+
`$GITHUB_TOKEN``gh auth token`.
71+
72+
### Changed
73+
74+
- `--fade-out-frames` defaults dynamically to `round(fade_out_duration × 4)` rather than
75+
a fixed 4, so a 2-second fade automatically uses 8 frames and a 0.5-second fade uses 2.
76+
3077
### Fixed
3178

3279
- **`--total-duration` overshooting the target length** — when many commits fell within
@@ -36,6 +83,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3683
non-floored frames are now scaled down to compensate so the sum always matches
3784
`--total-duration` exactly.
3885

86+
### Docs
87+
88+
- Added `## dirplot read-meta` section to `docs/CLI.md` (previously undocumented).
89+
- Documented external tool requirements: `git` (required by `dirplot git`), `ffmpeg`
90+
(required for MP4 output), `ffprobe` (required by `read-meta` on MP4 files) — in both
91+
`README.md` and `docs/CLI.md`.
92+
3993
## [0.4.0] - 2026-03-28
4094

4195
### Added

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Optional extras: `pip install "dirplot[ssh]"`, `"dirplot[s3]"`, `"dirplot[libarc
3434

3535
`dirplot watch` uses [watchdog](https://github.com/gorakhargosh/watchdog) for filesystem monitoring — installed automatically as a dependency.
3636

37+
`dirplot git` requires `git` on `PATH`. MP4 output (`dirplot git`, `dirplot watch`, `dirplot replay` with `--animate`) requires [ffmpeg](https://ffmpeg.org/) on `PATH`. `dirplot read-meta` on `.mp4` files also requires `ffprobe` (bundled with ffmpeg).
38+
3739
## Quick start
3840

3941
```bash

docs/CLI.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ dirplot map pod://my-pod:/app
106106

107107
Monitors directories and regenerates the treemap on every change. With `--animate`, each debounced render becomes one frame; the complete APNG or MP4 is written on Ctrl-C.
108108

109+
> **Requires** `ffmpeg` on `PATH` for MP4 output.
110+
109111
```bash
110112
# Watch and regenerate on every change
111113
dirplot watch . --output treemap.png
@@ -125,6 +127,11 @@ dirplot watch . --output treemap.png --animate
125127
dirplot watch . --output treemap.mp4 --animate
126128
dirplot watch . --output treemap.mp4 --animate --crf 18 # higher quality
127129
dirplot watch . --output treemap.mp4 --animate --codec libx265 # smaller file
130+
131+
# Fade out to black at the end (default: 1 s, 4 fps)
132+
dirplot watch . --output treemap.png --animate --fade-out
133+
dirplot watch . --output treemap.mp4 --animate --fade-out --fade-out-duration 2.0
134+
dirplot watch . --output treemap.png --animate --fade-out --fade-out-color transparent # APNG only
128135
```
129136

130137
### Options
@@ -135,6 +142,10 @@ dirplot watch . --output treemap.mp4 --animate --codec libx265 # smaller file
135142
| `--debounce` | `0.5` | Seconds of quiet before regenerating; `0` disables |
136143
| `--event-log` || Write raw events as JSONL on Ctrl-C exit |
137144
| `--animate` / `--no-animate` | off | Capture frames and write APNG or MP4 on Ctrl-C |
145+
| `--fade-out` / `--no-fade-out` | off | Append a fade-out sequence at the end (animate only) |
146+
| `--fade-out-duration` | `1.0` | Duration of the fade-out in seconds |
147+
| `--fade-out-frames` | 4 × duration | Number of fade frames; defaults to 4 per second |
148+
| `--fade-out-color` | `auto` | Fade target: `auto` (black/white per mode), `transparent` (PNG/APNG only), CSS name, or hex |
138149
| `--crf` | `23` | MP4 quality: 0 = lossless, 51 = worst. Ignored for APNG |
139150
| `--codec` | `libx264` | MP4 codec: `libx264` (H.264) or `libx265` (H.265) |
140151
| `--log` / `--no-log` | off | Log scale for file sizes |
@@ -151,6 +162,8 @@ dirplot watch . --output treemap.mp4 --animate --codec libx265 # smaller file
151162

152163
Replays a JSONL event log produced by `dirplot watch --event-log` as an animated treemap. Events are grouped into time buckets (one frame per bucket).
153164

165+
> **Requires** `ffmpeg` on `PATH` for MP4 output.
166+
154167
```bash
155168
# Replay as APNG (60-second buckets, 30-second total)
156169
dirplot replay events.jsonl --output replay.apng --total-duration 30
@@ -162,16 +175,24 @@ dirplot replay events.jsonl --output replay.mp4 --codec libx265 # smaller file
162175

163176
# Fine-grained buckets with fixed frame duration
164177
dirplot replay events.jsonl --output replay.apng --bucket 10 --frame-duration 200
178+
179+
# Fade out at the end
180+
dirplot replay events.jsonl --output replay.mp4 --total-duration 30 --fade-out
181+
dirplot replay events.jsonl --output replay.png --total-duration 30 --fade-out --fade-out-color white
165182
```
166183

167184
### Options
168185

169186
| Flag | Default | Description |
170187
|---|---|---|
171-
| `--output` / `-o` | required | Output `.apng` or `.mp4` |
188+
| `--output` / `-o` | required | Output `.png`, `.apng`, or `.mp4` |
172189
| `--bucket` | `60.0` | Time bucket size in seconds; one frame per bucket |
173190
| `--frame-duration` | `500` | Frame display time in ms (when `--total-duration` is not set) |
174191
| `--total-duration` || Target total animation length in seconds; frames scale proportionally to real time gaps |
192+
| `--fade-out` / `--no-fade-out` | off | Append a fade-out sequence at the end |
193+
| `--fade-out-duration` | `1.0` | Duration of the fade-out in seconds |
194+
| `--fade-out-frames` | 4 × duration | Number of fade frames; defaults to 4 per second |
195+
| `--fade-out-color` | `auto` | Fade target: `auto` (black/white per mode), `transparent` (PNG/APNG only), CSS name, or hex |
175196
| `--crf` | `23` | MP4 quality: 0 = lossless, 51 = worst. Ignored for APNG |
176197
| `--codec` | `libx264` | MP4 codec: `libx264` (H.264) or `libx265` (H.265) |
177198
| `--workers` / `-w` | all CPU cores | Parallel render workers |
@@ -189,6 +210,8 @@ dirplot replay events.jsonl --output replay.apng --bucket 10 --frame-duration 20
189210

190211
Renders a git repository's commit history as an animated treemap. Each commit becomes one frame; changed tiles are highlighted.
191212

213+
> **Requires** `git` on `PATH`. `ffmpeg` is also required for MP4 output.
214+
192215
The `repo` argument accepts:
193216
- Local path: `.`, `/path/to/repo`
194217
- Local path with ref: `.@my-branch`, `.@v1.0`, `.@abc1234`
@@ -222,6 +245,12 @@ dirplot git github://owner/repo@main --output history.apng --animate --max-commi
222245
dirplot git . --output history.mp4 --animate --last 30d
223246
dirplot git . --output history.mp4 --animate --last 24h
224247
dirplot git github://owner/repo --output history.mp4 --animate --last 2w --max-commits 10
248+
249+
# Fade out to black at the end (animate only)
250+
dirplot git . --output history.png --animate --fade-out
251+
dirplot git . --output history.mp4 --animate --fade-out --fade-out-duration 2.0
252+
dirplot git . --output history.png --animate --fade-out --fade-out-color transparent # APNG/PNG only
253+
dirplot git . --output history.mp4 --animate --fade-out --fade-out-color "#1a1a2e"
225254
```
226255

227256
### Options
@@ -235,6 +264,10 @@ dirplot git github://owner/repo --output history.mp4 --animate --last 2w --max-c
235264
| `--last` || Time-period filter: `30d`, `24h`, `2w`, `1mo`, `30m`. Uses `--shallow-since` for GitHub URLs |
236265
| `--frame-duration` | `1000` | Frame display time in ms (when `--total-duration` is not set) |
237266
| `--total-duration` || Target total animation length in seconds; frames scale proportionally to real time gaps between commits |
267+
| `--fade-out` / `--no-fade-out` | off | Append a fade-out sequence at the end (animate only) |
268+
| `--fade-out-duration` | `1.0` | Duration of the fade-out in seconds |
269+
| `--fade-out-frames` | 4 × duration | Number of fade frames; defaults to 4 per second |
270+
| `--fade-out-color` | `auto` | Fade target: `auto` (black/white per mode), `transparent` (PNG/APNG only), CSS name, or hex |
238271
| `--crf` | `23` | MP4 quality: 0 = lossless, 51 = worst. Ignored for APNG |
239272
| `--codec` | `libx264` | MP4 codec: `libx264` (H.264) or `libx265` (~40% smaller at same quality) |
240273
| `--workers` / `-w` | all CPU cores | Parallel render workers; 4–8 is typically optimal |
@@ -249,6 +282,21 @@ dirplot git github://owner/repo --output history.mp4 --animate --last 2w --max-c
249282

250283
---
251284

285+
## `dirplot read-meta` — read embedded metadata
286+
287+
Reads dirplot metadata (date, software version, OS, Python version, executed command) embedded in a PNG, SVG, or MP4/MOV output file.
288+
289+
> **Requires** `ffprobe` on `PATH` (bundled with [ffmpeg](https://ffmpeg.org/)) to read metadata from `.mp4` / `.mov` files.
290+
291+
```bash
292+
dirplot read-meta treemap.png
293+
dirplot read-meta treemap.svg
294+
dirplot read-meta history.mp4
295+
dirplot read-meta a.png b.png c.svg # multiple files
296+
```
297+
298+
---
299+
252300
## `dirplot demo` — run example commands
253301

254302
Runs a curated set of example commands covering each subcommand and saves outputs to a folder. Useful for a first-time walkthrough or to verify that everything works in your environment.
@@ -272,8 +320,9 @@ Examples produced:
272320
| `map-local.png` | `dirplot map .` (dark mode, PNG) |
273321
| `map-github.png` | `dirplot map github://owner/repo` (dark mode, PNG) |
274322
| `map-local.svg` | `dirplot map .` (light mode, SVG) |
275-
| `git.png` | `dirplot git github://owner/repo --max-commits 5` (static PNG) |
323+
| `git-static.png` | `dirplot git github://owner/repo --max-commits 5` (static PNG) |
276324
| `git.mp4` | `dirplot git github://owner/repo --max-commits 10 --animate --total-duration 20` |
325+
| `git-animated.png` | `dirplot git github://owner/repo --max-commits 10 --animate --total-duration 20 --fade-out` |
277326
| *(stdout)* | `dirplot read-meta map-local.png` |
278327

279328
`dirplot watch` and `dirplot replay` are listed but skipped with an explanatory note — both require interactive or pre-recorded input.

0 commit comments

Comments
 (0)