pgexplain 0.1.0 → 0.2.0

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.
package/README.md CHANGED
@@ -67,6 +67,34 @@ Point at a directory to analyze every plan in it (batch mode):
67
67
  pg-explain ./plans/
68
68
  ```
69
69
 
70
+ Or launch the local **Studio** — a GUI for everything the CLI does:
71
+
72
+ ```sh
73
+ pg-explain studio # opens http://127.0.0.1:5177 in your browser
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Studio (local web UI)
79
+
80
+ `pg-explain studio` starts a local, single-user web app (binds `127.0.0.1`, no auth) that
81
+ mirrors the CLI with a friendlier surface. It ships inside the package, so `npx pgexplain studio`
82
+ just works — the PostgreSQL driver and the UI are only loaded on demand.
83
+
84
+ - **Analyze** a pasted `EXPLAIN (FORMAT JSON)` plan, or **Run** a query (connect → EXPLAIN-only,
85
+ rollback-wrapped, read-only; non-`SELECT` refused unless forced).
86
+ - **Findings** as plain-language cards (what / why / fix + copy-paste commands + docs links).
87
+ - **Lock advisor** — static warnings (rewrites, missing `CONCURRENTLY`, unindexed `UPDATE/DELETE`,
88
+ unbounded `FOR UPDATE`, …) plus a **🔒 Live locks** view of current blocking chains.
89
+ - Interactive **plan tree** (heat-colored by self-time), **bottlenecks**, raw JSON.
90
+ - **History** of every run (SQLite under `~/.pgexplain`), **Compare** any two runs (structured
91
+ diff), and **Export** to Markdown / HTML / JSON.
92
+ - **Saved connections** and a **Settings** page to tune advisor thresholds (applied live).
93
+
94
+ Flags: `pg-explain studio [--port 5177] [--host 127.0.0.1] [--no-open] [--unsafe-host]`.
95
+ Binding a non-loopback host requires `--unsafe-host` (the studio can reach arbitrary databases,
96
+ so exposing it is an SSRF/credential risk). Set `PGEXPLAIN_DATA_DIR` to relocate the local store.
97
+
70
98
  ---
71
99
 
72
100
  ## Example output
@@ -180,12 +208,20 @@ Choose with `-f`/`--format` (default `terminal`); write to a file with `-o`/`--o
180
208
  | `terminal` | Color, severity heat, and proportional self-time bars for interactive use. |
181
209
  | `markdown` | The headline shareable deliverable — paste into a PR or ticket. |
182
210
  | `json` | Stable, machine-readable (`schemaVersion = 1`). |
183
- | `html` | Single self-contained file (no external assets). |
211
+ | `html` | Single self-contained file (no external assets). Auto-opens in your browser when run interactively. |
184
212
  | `text` | Plain text, no escapes — good for logs. |
185
213
 
186
214
  `diff` supports `terminal`, `markdown`, and `json`.
187
215
 
188
- Shared output flags: `--tldr` (summary + findings, no plan tree), `--redact` (strip literal values so the report is safe to share), `--ascii` (ASCII tree glyphs), `--color auto|always|never` / `--no-color`, `--compact` (compact JSON), `--config <path>`, `-q/--quiet`, `--verbose`, `--debug`.
216
+ When you run `-f html` in an interactive terminal, the report opens in your default browser automatically: with `-o report.html` that file is opened, otherwise a temp file is written and opened. Auto-open is off when output is piped/redirected or `CI` is set; use `--open` to force it (e.g. into a file in CI) and `--no-open` to disable it.
217
+
218
+ ```bash
219
+ pg-explain plan.json -f html -o report.html # writes the file and opens it
220
+ pg-explain plan.json -f html # writes a temp file and opens it
221
+ pg-explain plan.json -f html > report.html # redirected → no open, HTML to stdout
222
+ ```
223
+
224
+ Shared output flags: `--tldr` (summary + findings, no plan tree), `--redact` (strip literal values so the report is safe to share), `--open` / `--no-open` (HTML browser opening), `--ascii` (ASCII tree glyphs), `--color auto|always|never` / `--no-color`, `--compact` (compact JSON), `--config <path>`, `-q/--quiet`, `--verbose`, `--debug`.
189
225
 
190
226
  ---
191
227