glassbox 0.11.0 → 0.11.1-beta.1

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
@@ -87,11 +87,15 @@ Then you run `glassbox` again. Your previous annotations carry forward — match
87
87
 
88
88
  - **Split and unified diffs** with syntax-colored add/remove/context lines
89
89
  - **Line-level annotations** — click any line to add feedback with a category
90
+ - **Image and SVG diffs** — binary images and SVGs render side-by-side with a **difference overlay**, a **swipeable slice tool**, and pixel-precision zoom/pan. SVGs offer a *Code* / *Rendered* toggle so you can review either the source or the rasterized output.
91
+ - **Compare any two paths** — `glassbox --diff <A> <B>` reviews two arbitrary files or two arbitrary folders by path — no git repository required.
90
92
  - **Drag and drop** annotations to different lines
91
93
  - **Double-click** to edit, click the category badge to reclassify
92
94
  - **Collapsible folder tree** in the sidebar with file filter
93
95
  - **Resizable sidebar** and word wrap toggle
94
96
  - **Keyboard navigation** — `j`/`k` to move between files, `Cmd+Enter` to save
97
+ - **Go-to-definition and a nav stack** — click any symbol to jump to its definition, with back/forward through your trail
98
+ - **Themes** — built-in Dark, Light, High Contrast, Dracula, and Tokyo Night, plus a custom theme editor with live preview
95
99
  - **Session persistence** — reviews survive restarts, pick up where you left off
96
100
  - **Smart review reuse** — re-running `glassbox` on the same commit updates diffs in place and migrates annotations to their new line positions
97
101
  - **Stale annotation detection** — comments that can't be matched to the updated diff are flagged with a visual indicator
@@ -130,6 +134,8 @@ If you're learning a new language, onboarding to an unfamiliar codebase, or new
130
134
 
131
135
  Guided Review works in all three sidebar modes (folder, risk, and narrative) and runs independently of risk or narrative analysis. When enabled, risk and narrative analysis also adjust their output to be more detailed and educational.
132
136
 
137
+ <img src="assets/demo-guided-review.png" alt="Guided review notes inline with the diff" width="720">
138
+
133
139
  ### How to use it
134
140
 
135
141
  Click the shield or book icon in the sidebar to switch from the default folder view to risk or narrative mode. If you haven't configured an API key yet, a settings dialog will prompt you. Analysis runs once and results are cached for the session. To enable Guided Review, open the Settings dialog (gear icon) and check "Enable guided review."
@@ -216,6 +222,9 @@ glassbox --files "src/**/*.ts,lib/*.js"
216
222
  # Review entire codebase
217
223
  glassbox --all
218
224
 
225
+ # Compare two arbitrary files or folders by path (no git repo required)
226
+ glassbox --diff ./dist-old ./dist-new
227
+
219
228
  # Resume a previous review
220
229
  glassbox --resume
221
230
  ```
@@ -233,6 +242,7 @@ glassbox --resume
233
242
  | `--branch <name>` | Current branch vs the named branch |
234
243
  | `--files <patterns>` | Specific files (comma-separated globs) |
235
244
  | `--all` | Entire codebase (all tracked files) |
245
+ | `--diff <a> <b>` | Compare two arbitrary files or folders by path — no git repo required |
236
246
  | `--port <number>` | Port to run on (default: 4183) |
237
247
  | `--resume` | Resume the latest in-progress review for this mode |
238
248
  | `--browser` | Open in browser instead of desktop window |
@@ -254,6 +264,51 @@ Create `.glassbox/settings.json` in your project directory to configure per-proj
254
264
  |-----|-------------|
255
265
  | `appName` | Custom window title and Dock name (defaults to "Glassbox — _folder name_") |
256
266
 
267
+ ### Use as `git difftool`
268
+
269
+ Glassbox installs a companion binary, `glassbox-difftool`, that lets you register it as your `git difftool` so `git difftool --dir-diff <refA> <refB>` opens the diff in Glassbox automatically.
270
+
271
+ > Both binaries (`glassbox` + `glassbox-difftool`) are installed onto PATH together — `npm install -g glassbox` ships both via the `bin` map; the desktop app's **Install CLI** affordance symlinks both. If `glassbox` is on PATH but `glassbox-difftool` isn't (e.g. a pre-0.12 desktop install), re-run "Install CLI" from **Settings → General** to add the missing symlink.
272
+
273
+ The easiest way to register it is to let the CLI do it for you:
274
+
275
+ ```bash
276
+ glassbox --register-difftool # writes the three keys at --global scope
277
+ glassbox --register-difftool --local # only inside the current repo
278
+ glassbox --unregister-difftool # remove (only touches keys we set)
279
+ ```
280
+
281
+ If you already have a different `diff.tool` configured, `--register-difftool` refuses to clobber it; pass `--force` to overwrite. The same controls live under **Settings → General** in the app (Register / Re-register / Unregister buttons).
282
+
283
+ If you'd rather wire it up by hand, the equivalent config is:
284
+
285
+ ```bash
286
+ git config --global diff.tool glassbox
287
+ git config --global difftool.glassbox.cmd 'glassbox-difftool "$LOCAL" "$REMOTE"'
288
+ git config --global difftool.prompt false
289
+ ```
290
+
291
+ Then:
292
+
293
+ ```bash
294
+ git difftool --dir-diff HEAD~1 HEAD
295
+ ```
296
+
297
+ **Use `--dir-diff`, not the per-file mode.** Glassbox is a session-based reviewer; the per-file mode would launch a separate Glassbox instance for each changed file (and collide on the instance lock). `--dir-diff` invokes Glassbox once with both snapshots.
298
+
299
+ **Under the hood:** `git difftool --dir-diff` materializes its two snapshot directories asymmetrically — the right side is symlinks pointing into your working tree, which trips up plain `git diff --no-index`. `glassbox-difftool` dereferences those symlinks into a temp tree before handing the dirs to `glassbox --diff`, then cleans up on exit. Without the wrapper you'd see every modified file show up as a "deleted + added" pair instead of a modified entry.
300
+
301
+ **Alternative: skip git difftool entirely.** Glassbox's native ref-aware modes already cover the workflows `git difftool` is for and produce cleaner diffs (real `git diff`, not `--no-index`):
302
+
303
+ ```bash
304
+ glassbox --commit <sha> # review one commit
305
+ glassbox --range <from>..<to> # review a range
306
+ glassbox --branch main # current branch vs main
307
+ glassbox # uncommitted changes
308
+ ```
309
+
310
+ Most users will find the native modes preferable. The `git difftool` integration exists for muscle memory.
311
+
257
312
  ---
258
313
 
259
314
  ## AI integration
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli-difftool.ts
4
+ import { spawnSync } from "child_process";
5
+ import { cpSync, mkdtempSync, rmSync } from "fs";
6
+ import { tmpdir } from "os";
7
+ import { dirname, join } from "path";
8
+ import { fileURLToPath } from "url";
9
+ var args = process.argv.slice(2);
10
+ if (args.length < 2 || args[0].startsWith("-") || args[1].startsWith("-")) {
11
+ console.error("usage: glassbox-difftool <local-dir> <remote-dir> [extra glassbox args...]");
12
+ console.error("");
13
+ console.error("Configure as a git difftool:");
14
+ console.error(" git config --global diff.tool glassbox");
15
+ console.error(` git config --global difftool.glassbox.cmd 'glassbox-difftool "$LOCAL" "$REMOTE"'`);
16
+ console.error(" git config --global difftool.prompt false");
17
+ console.error("");
18
+ console.error("Then use `--dir-diff` (per-file mode collides with Glassbox's instance lock):");
19
+ console.error(" git difftool --dir-diff HEAD~1 HEAD");
20
+ process.exit(1);
21
+ }
22
+ var [local, remote, ...extra] = args;
23
+ var work = mkdtempSync(join(tmpdir(), "glassbox-difftool-"));
24
+ var resolvedLocal = join(work, "left");
25
+ var resolvedRemote = join(work, "right");
26
+ function cleanup() {
27
+ try {
28
+ rmSync(work, { recursive: true, force: true });
29
+ } catch {
30
+ }
31
+ }
32
+ var signalExit = (code) => () => {
33
+ cleanup();
34
+ process.exit(code);
35
+ };
36
+ process.on("SIGINT", signalExit(130));
37
+ process.on("SIGTERM", signalExit(143));
38
+ try {
39
+ cpSync(local, resolvedLocal, { recursive: true, dereference: true });
40
+ cpSync(remote, resolvedRemote, { recursive: true, dereference: true });
41
+ const here = dirname(fileURLToPath(import.meta.url));
42
+ const cli = join(here, "cli.js");
43
+ const res = spawnSync(process.execPath, [cli, "--diff", resolvedLocal, resolvedRemote, ...extra], {
44
+ stdio: "inherit"
45
+ });
46
+ process.exit(res.status ?? 0);
47
+ } finally {
48
+ cleanup();
49
+ }
50
+ //# sourceMappingURL=cli-difftool.js.map