codechart 0.6.0 → 0.7.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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  What's new in each codechart release. Update with `codechart update`; the [releases page](https://github.com/freeleex/codechart/releases) has the same notes.
4
4
 
5
+ ## 0.7.0 (2026-11-06)
6
+
7
+ ### New
8
+
9
+ - HTML: Focus button (◎, or `f`) zooms in on the node you are reviewing and centres it; that node now has a soft blue glow so you can tell it from its lit neighbours.
10
+ - HTML diffs: long runs of unchanged lines fold into "⋯ N unchanged lines" (click to open), and "⋯ N lines not in the diff" marks code between hunks.
11
+
12
+ ### Changed
13
+
14
+ - HTML diffs look like GitHub's: full-row red/green tints, line numbers, a quiet header per hunk. Every hunk starts collapsed.
15
+ - HTML: the Light/Full switch from 0.6.0 is gone; every page shows the full diff.
16
+ - HTML panel: the review tickbox sits left of the node title, the file path shows once, and relations are two columns (← Used by, Uses →).
17
+ - HTML header: the build time reads like `6 Nov 2026, 19:44`.
18
+
5
19
  ## 0.6.0 (2026-11-06)
6
20
 
7
21
  ### New
package/README.md CHANGED
@@ -153,7 +153,7 @@ On the full page, a changed resource shows its HCL diff and changed attributes (
153
153
 
154
154
  ### Terminal first, page when it helps
155
155
 
156
- Small diagrams stay in the reply. Big ones also get a self-contained HTML page: zoom, pan, light and dark themes, a node panel with back/forward through the nodes you opened and a list of the node's links (selecting a node dims all but it and its neighbours; Esc clears), a row of status chips under the header that count, explain and fade nodes (*Δ changes only* hides the context), nothing loaded from the internet. In a change summary, a node's diff is read from git when the page is built, so the agent spends no tokens on it (lockfiles, minified bundles, `dist/` and files marked `linguist-generated` are skipped). A header switch picks **Light** (default: the first 3 hunks of each diff, with a *see all in Full* hint) or **Full**: the whole diff (up to 1000 lines per file) as foldable hunks, tickboxes to mark nodes reviewed (*7/12 reviewed*, *Next unreviewed*; a tick lasts until the node's diff changes) a pager bar (‹ 3 / 10 ›, *+ all* / *− all*) and keys: `n`/`p` hunks (open one, fold the rest), `]`/`[` unreviewed nodes, `r` reviewed, `o`/`O` fold, `?` help.
156
+ Small diagrams stay in the reply. Big ones also get a self-contained HTML page: zoom, pan, light and dark themes, a node panel with back/forward through the nodes you opened and a *Used by* / *Uses* list of the node's links (selecting a node dims all but it and its neighbours; Esc clears), a row of status chips under the header that count, explain and fade nodes (*Δ changes only* hides the context), nothing loaded from the internet. In a change summary, a node's diff is read from git when the page is built, so the agent spends no tokens on it (lockfiles, minified bundles, `dist/` and files marked `linguist-generated` are skipped). Each node's panel shows the whole diff (up to 1000 lines per file) as foldable hunks in a GitHub-style layout (full-row red/green tints, line numbers, long unchanged runs collapsed into a click-to-open row), a tickbox left of the panel title to mark the node reviewed (*7/12 reviewed* in that row, *Next unreviewed*; a tick lasts until the node's diff changes) a pager bar (‹ 3 / 10 ›, *+ all* / *− all*) and keys: `n`/`p` hunks (open one, fold the rest; every hunk starts folded), `f` zoom to the selected node (also a ◎ button next to the panel's ← →; the selected node has a blue glow, so you can tell it from its lit neighbours), `]`/`[` unreviewed nodes, `r` reviewed, `o`/`O` fold, `?` help.
157
157
 
158
158
  ### Maps in pull requests
159
159
 
@@ -184,7 +184,7 @@ The skill fires when the agent summarizes a change, writes a plan or explains ho
184
184
 
185
185
  A diagram is about **2–3 extra API calls**. In a long session that's roughly 2–3% of your usage per diagram, and nothing for trivial changes. That's an estimate from Claude Code sessions with Sonnet; other agents and models will differ, and shorter sessions pay proportionally more. Measured runs are in [docs/efficiency.md](docs/efficiency.md).
186
186
 
187
- The CLI is small: a 110.3 kB package, 5 runtime dependencies, and a cold start around 150 ms.
187
+ The CLI is small: a 112.2 kB package, 5 runtime dependencies, and a cold start around 150 ms.
188
188
 
189
189
  ## Safe to run
190
190
 
package/dist/cli.js CHANGED
@@ -618,9 +618,9 @@ function gitParent(cwd, sha) {
618
618
  function gitEmptyTree(cwd) {
619
619
  return git(cwd, ["hash-object", "-t", "tree", "--stdin"], { input: "" }).trim();
620
620
  }
621
- function gitMergeBase(cwd, base, head = "HEAD") {
621
+ function gitMergeBase(cwd, base, head2 = "HEAD") {
622
622
  checkRef("--since", base);
623
- return git(cwd, ["merge-base", base, head]).trim();
623
+ return git(cwd, ["merge-base", base, head2]).trim();
624
624
  }
625
625
  function gitBlobSizes(cwd, specs) {
626
626
  if (!specs.length) return [];
@@ -710,10 +710,10 @@ function gitFileDiffs(cwd, range, rels, maxBytes) {
710
710
  for (const [i, start] of starts.entries()) {
711
711
  const end = starts[i + 1] ?? text.length;
712
712
  const eol = text.indexOf("\n", start);
713
- const head = text.slice(start + "diff --git ".length, eol < 0 ? end : eol);
714
- const len = (head.length - "a/ b/".length) / 2;
715
- const rel = head.slice("a/".length, "a/".length + len);
716
- if (!Number.isInteger(len) || head !== `a/${rel} b/${rel}` || !wanted.has(rel)) return void 0;
713
+ const head2 = text.slice(start + "diff --git ".length, eol < 0 ? end : eol);
714
+ const len = (head2.length - "a/ b/".length) / 2;
715
+ const rel = head2.slice("a/".length, "a/".length + len);
716
+ if (!Number.isInteger(len) || head2 !== `a/${rel} b/${rel}` || !wanted.has(rel)) return void 0;
717
717
  out.set(rel, (out.get(rel) ?? "") + text.slice(start, end));
718
718
  }
719
719
  }
@@ -739,10 +739,10 @@ function gitCommitFiles(cwd, ref) {
739
739
  if (!parent) return nulList(git(cwd, ["diff-tree", "-r", "--root", "--no-commit-id", "--name-only", "-z", sha]));
740
740
  return nulList(git(cwd, ["diff", "--no-renames", "--name-only", "-z", parent, sha, "--"]));
741
741
  }
742
- function gitSinceFiles(cwd, base, head = "HEAD") {
742
+ function gitSinceFiles(cwd, base, head2 = "HEAD") {
743
743
  checkRef("--since", base);
744
- checkRef("--head", head);
745
- return nulList(git(cwd, ["diff", "--no-renames", "--name-only", "-z", `${base}...${head}`, "--"]));
744
+ checkRef("--head", head2);
745
+ return nulList(git(cwd, ["diff", "--no-renames", "--name-only", "-z", `${base}...${head2}`, "--"]));
746
746
  }
747
747
  function gitListFiles(cwd, sha) {
748
748
  return nulList(
@@ -810,8 +810,8 @@ function diffRange(root, o) {
810
810
  return { args: [parent, sha], revs: [parent, sha], worktree: false, config };
811
811
  }
812
812
  if (o.since !== void 0 && !o.git) {
813
- const head = resolveCommit(root, "--head", o.head ?? "HEAD");
814
- return { args: [`${o.since}...${head}`], revs: [gitMergeBase(root, o.since, head), head], worktree: false, config };
813
+ const head2 = resolveCommit(root, "--head", o.head ?? "HEAD");
814
+ return { args: [`${o.since}...${head2}`], revs: [gitMergeBase(root, o.since, head2), head2], worktree: false, config };
815
815
  }
816
816
  const from = o.since !== void 0 ? gitMergeBase(root, o.since) : gitHead(root) ?? gitEmptyTree(root);
817
817
  return { args: [from], revs: [from], worktree: true, config: [...config, ...repoFilterOverrides(root)] };
@@ -918,10 +918,10 @@ function renderPieces(pieces) {
918
918
  }
919
919
  return merged.map((p) => p.item?.paint ? p.item.paint(p.text) : p.text).join("");
920
920
  }
921
- function wrapItems(head, items2, width) {
922
- const indent = " ".repeat(columns(head));
921
+ function wrapItems(head2, items2, width) {
922
+ const indent = " ".repeat(columns(head2));
923
923
  const lines = [];
924
- let line = [{ text: head }];
924
+ let line = [{ text: head2 }];
925
925
  let fresh = true;
926
926
  const room = () => width - line.reduce((n, p) => n + columns(p.text), 0);
927
927
  const append = (text, item) => {
@@ -1603,8 +1603,8 @@ function pickerLines(title, items2, s, width = Infinity) {
1603
1603
  return [
1604
1604
  cut(title, width),
1605
1605
  ...items2.map((it, i) => {
1606
- const head = cut(`${i === s.cursor ? "\u276F" : " "} ${s.checked[i] ? "\u25C9" : "\u25EF"} ${it.label.padEnd(pad2)} `, width);
1607
- return head + dim(cut(it.hint, width - head.length));
1606
+ const head2 = cut(`${i === s.cursor ? "\u276F" : " "} ${s.checked[i] ? "\u25C9" : "\u25EF"} ${it.label.padEnd(pad2)} `, width);
1607
+ return head2 + dim(cut(it.hint, width - head2.length));
1608
1608
  }),
1609
1609
  dim(cut("\u2191/\u2193 move \xB7 Space toggle \xB7 a all \xB7 Enter confirm \xB7 Esc cancel", width))
1610
1610
  ];
@@ -2408,11 +2408,11 @@ function checkTag(c) {
2408
2408
  const total = c.unit === "node" ? String(c.checked) : units(c.checked, c.unit);
2409
2409
  return ` \xB7 \u2713 ${c.mismatches.length ? `${c.checked - c.mismatches.length} of ` : ""}${total} checked${unchecked}`;
2410
2410
  }
2411
- function itemsLine(head, all, width) {
2411
+ function itemsLine(head2, all, width) {
2412
2412
  const items2 = all.slice(0, MAX_SHOWN);
2413
2413
  if (all.length > MAX_SHOWN) items2.push(`+${all.length - MAX_SHOWN} more`);
2414
- if (columns(head) <= width / 2) return wrapItems(head, items2, width);
2415
- return `${truncate(head.trimEnd(), width)}
2414
+ if (columns(head2) <= width / 2) return wrapItems(head2, items2, width);
2415
+ return `${truncate(head2.trimEnd(), width)}
2416
2416
  ${wrapItems(" ", items2, width)}`;
2417
2417
  }
2418
2418
  function alertLine(c, width) {
@@ -2426,14 +2426,14 @@ function alertLine(c, width) {
2426
2426
  function webAlert(c, width) {
2427
2427
  return [alertLine(c, width), c?.diffUnchecked ? UNCHECKED : ""].filter(Boolean).join("\n");
2428
2428
  }
2429
- function countLines(counts, c, width) {
2429
+ function countLines(counts2, c, width) {
2430
2430
  const tag2 = checkTag(c);
2431
- if (columns(counts + tag2) <= width) return counts + tag2;
2432
- if (!tag2) return truncate(counts, width);
2431
+ if (columns(counts2 + tag2) <= width) return counts2 + tag2;
2432
+ if (!tag2) return truncate(counts2, width);
2433
2433
  const parts = tag2.replace(/^ · /, "").split(" \xB7 ");
2434
2434
  const joined = parts.join(" \xB7 ");
2435
2435
  const rest = columns(joined) <= width ? [joined] : parts.map((p) => truncate(p, width));
2436
- return [truncate(counts, width), ...rest].join("\n");
2436
+ return [truncate(counts2, width), ...rest].join("\n");
2437
2437
  }
2438
2438
  function checkHeadline(c) {
2439
2439
  if (!c) return "";
@@ -2460,11 +2460,11 @@ var gutter = (status) => `${marker(status) || " "} `;
2460
2460
  import { createHash as createHash2 } from "crypto";
2461
2461
 
2462
2462
  // src/render/web/styles.ts
2463
- var DARK_VARS = "--bg:#0f1115;--panel:#161b22;--card:#161b22;--line:#30363d;--text:#c9d1d9;--muted:#8b949e;--edge:#79c0ff;--new:#3fb950;--new-t:#7ee787;--chg:#d29922;--chg-t:#f2cc60;--cfg:#a371f7;--cfg-t:#d2a8ff;--add:#7ee787;--rem:#ff7b72";
2463
+ var DARK_VARS = "--bg:#0f1115;--panel:#161b22;--card:#161b22;--line:#30363d;--text:#c9d1d9;--muted:#8b949e;--edge:#79c0ff;--new:#3fb950;--new-t:#7ee787;--chg:#d29922;--chg-t:#f2cc60;--cfg:#a371f7;--cfg-t:#d2a8ff;--add:#7ee787;--rem:#ff7b72;--add-bg:rgba(46,160,67,.22);--rem-bg:rgba(248,81,73,.22);--gap-bg:rgba(110,118,129,.12);--hh-bg:rgba(56,139,253,.10);--hh-line:rgba(56,139,253,.28);--ln:#484f58;--ln-add:rgba(126,231,135,.55);--ln-rem:rgba(255,123,114,.55)";
2464
2464
  var DARK_AUTO = `@media (prefers-color-scheme: dark){:root[data-theme="auto"]{${DARK_VARS}}}`;
2465
2465
  var DARK_FORCED = `:root[data-theme="dark"]{${DARK_VARS}}`;
2466
2466
  var CSS = `
2467
- :root{color-scheme:light dark;--bg:#f6f8fa;--panel:#fff;--card:#fff;--line:#d0d7de;--text:#1f2328;--muted:#656d76;--edge:#0969da;--new:#2ea043;--new-t:#1a7f37;--chg:#d29922;--chg-t:#9a6700;--cfg:#8957e5;--cfg-t:#8250df;--add:#1a7f37;--rem:#cf222e}
2467
+ :root{color-scheme:light dark;--bg:#f6f8fa;--panel:#fff;--card:#fff;--line:#d0d7de;--text:#1f2328;--muted:#656d76;--edge:#0969da;--new:#2ea043;--new-t:#1a7f37;--chg:#d29922;--chg-t:#9a6700;--cfg:#8957e5;--cfg-t:#8250df;--add:#1a7f37;--rem:#cf222e;--add-bg:rgba(46,160,67,.18);--rem-bg:rgba(255,129,130,.25);--gap-bg:rgba(110,118,129,.12);--hh-bg:rgba(9,105,218,.07);--hh-line:rgba(9,105,218,.22);--ln:var(--muted);--ln-add:rgba(26,127,55,.6);--ln-rem:rgba(207,34,46,.6)}
2468
2468
  :root[data-theme="light"]{color-scheme:light}
2469
2469
  :root[data-theme="dark"]{color-scheme:dark}
2470
2470
  ${DARK_AUTO}
@@ -2493,10 +2493,13 @@ aside{width:clamp(300px,35vw,600px);min-width:300px;max-width:80vw;border-left:1
2493
2493
  #panel-nav button{padding:0 7px;font:13px/20px system-ui,sans-serif;color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:10px;cursor:pointer}
2494
2494
  #panel-nav button:hover:not(:disabled){border-color:var(--edge)}#panel-nav button:disabled{opacity:.4;cursor:default}
2495
2495
  aside h2{margin:0 0 6px;font-size:13px;overflow-wrap:anywhere}
2496
+ aside .ptitle{display:flex;gap:7px;align-items:flex-start;min-height:26px;margin-bottom:8px;line-height:1.35}aside .ptitle input{flex:none;margin:2px 0 0}
2496
2497
  aside h3{margin:12px 0 4px;font-size:11px;text-transform:uppercase;color:var(--muted)}
2498
+ aside h3.ch-head{display:flex;justify-content:space-between;align-items:baseline}aside .ch-head .fh-stat{font:11px ui-monospace,monospace;text-transform:none}
2499
+ aside h4{margin:0 0 2px;font-size:11px;font-weight:600;color:var(--muted)}
2497
2500
  aside ul{margin:0;padding-left:18px}
2498
- aside .tick-row{display:block;margin:0 0 6px;color:var(--muted)}
2499
- aside .relations{list-style:none;padding:0}
2501
+ aside .relations{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:6px 14px}
2502
+ aside .rel-col ul{list-style:none;padding:0}aside .rel-none{margin:0;color:var(--muted);font-style:italic}
2500
2503
  aside .rel{padding:1px 0;font:inherit;color:var(--edge);background:none;border:0;cursor:pointer;text-align:left;overflow-wrap:anywhere}aside .rel:hover{text-decoration:underline}
2501
2504
  aside .fields-note{color:var(--muted);font-size:11.5px;font-style:italic;margin:6px 0 0}
2502
2505
  aside code{font-family:ui-monospace,monospace;font-size:11px;font-style:normal}
@@ -2504,8 +2507,18 @@ aside .path{font-family:ui-monospace,monospace;font-size:11px;overflow-wrap:anyw
2504
2507
  aside .snippet{font:11px/1.45 ui-monospace,monospace;background:var(--bg);border:1px solid var(--line);border-radius:4px;padding:6px 8px;margin:6px 0;white-space:pre-wrap;overflow-wrap:anywhere}
2505
2508
  aside .snippet code{display:grid;grid-template-columns:auto minmax(0,1fr);column-gap:10px}
2506
2509
  aside .snippet .ln{min-width:3ch;color:var(--muted);text-align:right;user-select:none}
2507
- aside .dr{display:flex}aside .dr .sg{flex:none;width:1ch;margin-right:1ch;user-select:none}aside .ind{white-space:pre;tab-size:4}aside .dr .cd{flex:1;min-width:0;white-space:pre-wrap;overflow-wrap:anywhere}
2508
- aside .d-add{color:var(--add)}aside .d-del{color:var(--rem)}aside .d-hunk{color:var(--muted)}
2510
+ aside .snippet.diff{background:none;border:0;border-radius:0;padding:0;margin:2px 0}
2511
+ aside .snippet.diff code{display:flex;flex-direction:column}
2512
+ aside .dr{display:flex;padding:0 14px 0 4px}
2513
+ aside .dr .ln{flex:none;width:4.5ch;min-width:0;color:var(--ln);text-align:right;user-select:none}
2514
+ aside .dr .sg{flex:none;width:2.4ch;text-align:center;user-select:none}
2515
+ aside .ind{white-space:pre;tab-size:4}aside .dr .cd{flex:1;min-width:0;white-space:pre-wrap;overflow-wrap:anywhere}
2516
+ aside .dr.d-add{background:var(--add-bg)}aside .dr.d-add .ln{color:var(--ln-add)}aside .dr.d-add .sg{color:var(--add)}
2517
+ aside .dr.d-del{background:var(--rem-bg)}aside .dr.d-del .ln{color:var(--ln-rem)}aside .dr.d-del .sg{color:var(--rem)}
2518
+ aside .n-add{color:var(--add)}aside .n-del{color:var(--rem)}
2519
+ aside .cgap{display:flex;flex-direction:column}aside .cgap .gap-rows{display:none;flex-direction:column}aside .cgap.open .gap-rows{display:flex}
2520
+ aside .gap{display:flex;width:100%;padding:2px 14px 2px calc(4px + 4.5ch);font:11px ui-monospace,monospace;color:var(--muted);background:var(--gap-bg);text-align:left;white-space:nowrap}
2521
+ aside button.gap{border:0;cursor:pointer}aside button.gap:hover{color:var(--text)}
2509
2522
  aside .mismatch-note{color:var(--rem);margin:6px 0}
2510
2523
  aside .mismatch-why{color:var(--muted);font-size:11.5px;margin:0 0 6px}
2511
2524
  header .check{font-size:11px;color:var(--new-t)}header .check.bad{color:var(--rem);font-weight:600;font-family:inherit;background:none;border:0;padding:0;cursor:pointer;text-decoration:underline dotted}
@@ -2549,6 +2562,8 @@ body.focus .node:not(.lit),body.focus .edge:not(.lit){--dim:.25}
2549
2562
  .node.reviewed :is(.card,.fold,.shape){stroke:var(--muted)}
2550
2563
  .node.reviewed .tick-box{fill:var(--muted)}.node.reviewed .tick-mark{display:inline}
2551
2564
  .node.selected .card{stroke-width:2.5}
2565
+ .node.selected{filter:drop-shadow(0 0 6px color-mix(in srgb,var(--edge) 45%,transparent))}
2566
+ .node.selected :is(.card,.shape){stroke-width:3}
2552
2567
  .node:focus{outline:none}
2553
2568
  .node:focus-visible .card{stroke:var(--edge);stroke-width:3.5}
2554
2569
  .status-new :is(.card,.fold){stroke:var(--new)}.status-new .badge{fill:var(--new-t)}
@@ -2559,24 +2574,24 @@ body.focus .node:not(.lit),body.focus .edge:not(.lit){--dim:.25}
2559
2574
  .field-added-t{color:var(--add)}.field-removed-t{color:var(--muted);text-decoration:line-through}.field-modified-t{color:var(--chg-t)}
2560
2575
 
2561
2576
  #info-toggle[aria-expanded="true"]{border-color:var(--edge)}
2562
- #info-toggle,#link-toggle,#mode-toggle,#theme-toggle{align-self:center;padding:4px 10px;font:11px system-ui,sans-serif;color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:12px;cursor:pointer}
2563
- #info-toggle:hover,#link-toggle:hover,#mode-toggle:hover,#theme-toggle:hover,#next-unreviewed:hover:not(:disabled){border-color:var(--edge)}
2577
+ #info-toggle,#link-toggle,#theme-toggle{align-self:center;padding:4px 10px;font:11px system-ui,sans-serif;color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:12px;cursor:pointer}
2578
+ #info-toggle:hover,#link-toggle:hover,#theme-toggle:hover,#next-unreviewed:hover:not(:disabled){border-color:var(--edge)}
2564
2579
  #next-unreviewed{padding:0 8px;font:10.5px/16px system-ui,sans-serif;color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:10px;cursor:pointer}
2565
2580
  #next-unreviewed:disabled{opacity:.4;cursor:default}
2566
- html[data-mode="light"] .fo,html[data-mode="full"] .lo{display:none!important}
2567
- aside .file-head{display:flex;gap:8px;align-items:baseline;justify-content:space-between;margin:6px 0 2px;color:var(--muted);font-size:11px}
2581
+ aside .file{margin:6px -14px}
2582
+ aside .file-head{display:flex;gap:8px;align-items:baseline;justify-content:space-between;margin:0 0 4px;padding:0 14px;color:var(--muted);font-size:11px}
2568
2583
  aside .file-head .path{min-width:0}
2569
- aside .hunk{margin-left:-8px;padding-left:5px;border-left:3px solid transparent}
2584
+ aside .hunk{border-left:3px solid transparent}aside .hunk+.hunk{margin-top:4px}
2570
2585
  aside .hunk.cur{border-left-color:var(--edge)}
2571
- aside .hunk-sum{display:flex;gap:8px;align-items:baseline;width:100%;padding:1px 0;font:11px ui-monospace,monospace;color:var(--muted);background:none;border:0;text-align:left;cursor:pointer;white-space:nowrap;overflow:hidden}
2572
- aside .hunk-sum:hover{color:var(--text)}
2573
- aside .hunk-sum>*{flex:none}
2574
- aside .hunk-sum .caret::before{content:"\\25BE"}aside .hunk.folded .caret::before{content:"\\25B8"}
2575
- aside .hunk-sum .hs-fn{flex:0 1 auto;max-width:50%;min-width:0;overflow:hidden;text-overflow:ellipsis;color:var(--edge)}
2576
- aside .hunk-sum .hs-first{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis}
2577
- html[data-mode="full"] aside .hunk.folded .hunk-body{display:none}
2578
- html[data-mode="full"] aside .hunk.folded{margin-bottom:0}
2579
- aside .see-full{padding:0;font:inherit;color:var(--edge);background:none;border:0;cursor:pointer}aside .see-full:hover{text-decoration:underline}
2586
+ aside .hh{display:flex;gap:8px;align-items:baseline;width:100%;padding:2px 14px 2px 5px;font:11px ui-monospace,monospace;color:var(--muted);background:var(--hh-bg);border:0;border-top:1px solid var(--hh-line);border-bottom:1px solid var(--hh-line);text-align:left;white-space:nowrap;overflow:hidden}
2587
+ aside button.hunk-sum{cursor:pointer}aside button.hunk-sum:hover{color:var(--text)}
2588
+ aside .hh>*{flex:none}
2589
+ aside .hh .caret{width:1ch}aside .hh .caret::before{content:"\\2304"}aside .hunk.folded .hh .caret::before{content:"\\203A"}
2590
+ aside .hh .hs-fn{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;color:var(--edge)}
2591
+ aside .hh .hs-first{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis}
2592
+ aside .hh .hs-stat{margin-left:auto}
2593
+ aside .hunk:not(.folded) .hs-first{display:none}
2594
+ aside .hunk.folded .hunk-body,aside .hunk.folded .gap-out{display:none}
2580
2595
  aside .hunk-end{margin:6px 0;color:var(--muted);font-size:11px;font-style:italic}
2581
2596
  #key-help{position:fixed;right:14px;bottom:14px;z-index:5;padding:8px 12px;font-size:11.5px;line-height:1.6;background:var(--panel);border:1px solid var(--line);border-radius:6px;box-shadow:0 2px 8px #0003;cursor:pointer}
2582
2597
  #key-help[hidden]{display:none}
@@ -2886,23 +2901,80 @@ var CLIENT_JS = [
2886
2901
  " return { paint, step, toggleSelected };",
2887
2902
  "}",
2888
2903
  "",
2889
- "const MODE_KEY = 'codechart.mode';",
2890
- "const isFull = () => document.documentElement.getAttribute('data-mode') === 'full';",
2891
- "function initMode(panel) {",
2892
- " const btn = document.getElementById('mode-toggle');",
2893
- " if (!btn)",
2894
- " return;",
2895
- " const set = (full, remember) => {",
2896
- " document.documentElement.setAttribute('data-mode', full ? 'full' : 'light');",
2897
- " btn.textContent = `Mode: ${full ? 'Full' : 'Light'}`;",
2904
+ "const ZOOM_MAX = 1.5;",
2905
+ "const FILL = 0.35;",
2906
+ "const GLIDE_MS = 250;",
2907
+ "function nodeView(b, pane) {",
2908
+ " const k = Math.min(ZOOM_MAX, (pane.width * FILL) / (b.width || 1), (pane.height * FILL) / (b.height || 1));",
2909
+ " return { k, x: pane.width / 2 - (b.x + b.width / 2) * k, y: pane.height / 2 - (b.y + b.height / 2) * k };",
2910
+ "}",
2911
+ "function glide(from, to, set) {",
2912
+ " var _a;",
2913
+ " if (((_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(prefers-reduced-motion: reduce)').matches) || !window.requestAnimationFrame) {",
2914
+ " set(to);",
2915
+ " return () => { };",
2916
+ " }",
2917
+ " let live = true;",
2918
+ " const t0 = performance.now();",
2919
+ " const step = (now) => {",
2920
+ " if (!live)",
2921
+ " return;",
2922
+ " const f = Math.min(1, (now - t0) / GLIDE_MS);",
2923
+ " const e = 1 - (1 - f) ** 3;",
2924
+ " set({ x: from.x + (to.x - from.x) * e, y: from.y + (to.y - from.y) * e, k: from.k + (to.k - from.k) * e });",
2925
+ " if (f < 1)",
2926
+ " requestAnimationFrame(step);",
2927
+ " };",
2928
+ " requestAnimationFrame(step);",
2929
+ " return () => {",
2930
+ " live = false;",
2931
+ " };",
2932
+ "}",
2933
+ "",
2934
+ "function initPanelResize() {",
2935
+ " const aside = document.querySelector('aside');",
2936
+ " const handle = document.getElementById('resize');",
2937
+ " let width = 0;",
2938
+ " const panes = !!document.getElementById('panes');",
2939
+ " const widthKey = panes ? 'codechart.panel.panes' : 'codechart.panel';",
2940
+ " const minWidth = panes ? 200 : 300;",
2941
+ " const setWidth = (w, remember) => {",
2942
+ " width = Math.round(Math.max(minWidth, Math.min(w, window.innerWidth * 0.8)));",
2943
+ " aside.style.width = `${width}px`;",
2898
2944
  " if (remember)",
2899
- " save(MODE_KEY, full ? 'full' : 'light');",
2945
+ " save(widthKey, String(width));",
2900
2946
  " };",
2901
- " set(load(MODE_KEY) === 'full', false);",
2902
- " btn.addEventListener('click', () => set(!isFull(), true));",
2903
- " panel.addEventListener('click', (e) => {",
2904
- ` if (e.target.closest('[data-mode-set="full"]'))`,
2905
- " set(true, true);",
2947
+ " const currentWidth = () => width || aside.getBoundingClientRect().width;",
2948
+ " const savedWidth = Number(load(widthKey));",
2949
+ " if (savedWidth > 0)",
2950
+ " setWidth(savedWidth, false);",
2951
+ " let sizing = false;",
2952
+ " handle.addEventListener('pointerdown', (e) => {",
2953
+ " sizing = true;",
2954
+ " handle.classList.add('drag');",
2955
+ " if (handle.setPointerCapture)",
2956
+ " handle.setPointerCapture(e.pointerId);",
2957
+ " e.preventDefault();",
2958
+ " });",
2959
+ " handle.addEventListener('pointermove', (e) => {",
2960
+ " if (sizing)",
2961
+ " setWidth(window.innerWidth - e.clientX, false);",
2962
+ " });",
2963
+ " const endSize = () => {",
2964
+ " if (!sizing)",
2965
+ " return;",
2966
+ " sizing = false;",
2967
+ " handle.classList.remove('drag');",
2968
+ " setWidth(currentWidth(), true);",
2969
+ " };",
2970
+ " handle.addEventListener('pointerup', endSize);",
2971
+ " handle.addEventListener('pointercancel', endSize);",
2972
+ " handle.addEventListener('keydown', (e) => {",
2973
+ " const step = e.key === 'ArrowLeft' ? 40 : e.key === 'ArrowRight' ? -40 : 0;",
2974
+ " if (!step)",
2975
+ " return;",
2976
+ " e.preventDefault();",
2977
+ " setWidth(currentWidth() + step, true);",
2906
2978
  " });",
2907
2979
  "}",
2908
2980
  "",
@@ -3002,7 +3074,7 @@ var CLIENT_JS = [
3002
3074
  " },",
3003
3075
  " };",
3004
3076
  "}",
3005
- "function initHunks(panel, review) {",
3077
+ "function initHunks(panel, review, zoomToNode) {",
3006
3078
  " const nav = walker(panel, panel.closest('aside'));",
3007
3079
  " const help = document.getElementById('key-help');",
3008
3080
  " const toggleHelp = () => {",
@@ -3014,6 +3086,7 @@ var CLIENT_JS = [
3014
3086
  " ']': () => review.step(1),",
3015
3087
  " '[': () => review.step(-1),",
3016
3088
  " r: () => review.toggleSelected(),",
3089
+ " f: zoomToNode,",
3017
3090
  " o: () => nav.toggle(),",
3018
3091
  " O: () => nav.toggleAll(),",
3019
3092
  " '?': toggleHelp,",
@@ -3031,6 +3104,9 @@ var CLIENT_JS = [
3031
3104
  " const h = (_a = t.closest('.hunk-sum')) === null || _a === void 0 ? void 0 : _a.closest('.hunk');",
3032
3105
  " if (h)",
3033
3106
  " nav.pick(h);",
3107
+ " const gap = t.closest('.gap-run');",
3108
+ " if (gap)",
3109
+ " gap.setAttribute('aria-expanded', String(gap.parentElement.classList.toggle('open')));",
3034
3110
  " for (const [sel, run] of Object.entries(buttons))",
3035
3111
  " if (t.closest(sel))",
3036
3112
  " run();",
@@ -3041,7 +3117,7 @@ var CLIENT_JS = [
3041
3117
  " window.addEventListener('keydown', (e) => {",
3042
3118
  " if (e.key === 'Escape')",
3043
3119
  " help.hidden = true;",
3044
- " if (e.ctrlKey || e.metaKey || e.altKey || typing(e.target) || !isFull())",
3120
+ " if (e.ctrlKey || e.metaKey || e.altKey || typing(e.target))",
3045
3121
  " return;",
3046
3122
  " const run = Object.hasOwn(keys, e.key) ? keys[e.key] : undefined;",
3047
3123
  " if (!run)",
@@ -3059,12 +3135,14 @@ var CLIENT_JS = [
3059
3135
  "const panel = document.getElementById('panel');",
3060
3136
  "const info = document.getElementById('page-info');",
3061
3137
  "const infoBtn = document.getElementById('info-toggle');",
3138
+ "const focusBtn = document.getElementById('nav-focus');",
3062
3139
  "let ts = canvases.map(() => ({ x: 0, y: 0, k: 1 }));",
3063
3140
  "let linked = true;",
3064
3141
  "let last = 0;",
3065
3142
  "let drag = null;",
3066
3143
  "let moved = false;",
3067
3144
  "let trail;",
3145
+ "let stopGlide = () => { };",
3068
3146
  "function apply() {",
3069
3147
  " vps.forEach((vp, i) => {",
3070
3148
  " const t = ts[i];",
@@ -3076,6 +3154,23 @@ var CLIENT_JS = [
3076
3154
  " ts = ts.map((old, j) => (linked || j === i ? { x: t.x, y: t.y, k: t.k } : old));",
3077
3155
  " apply();",
3078
3156
  "}",
3157
+ "function zoomToSelected() {",
3158
+ " var _a;",
3159
+ " const id = (_a = document.querySelector('.node.selected')) === null || _a === void 0 ? void 0 : _a.getAttribute('data-id');",
3160
+ " if (!id)",
3161
+ " return;",
3162
+ " stopGlide();",
3163
+ " const stops = [];",
3164
+ " for (let i = 0; i < canvases.length; i++) {",
3165
+ ' const g = canvases[i].querySelector(`.node[data-id="${CSS.escape(id)}"]`);',
3166
+ " if (!g)",
3167
+ " continue;",
3168
+ " stops.push(glide(ts[i], nodeView(g.getBBox(), canvases[i].querySelector('svg').getBoundingClientRect()), (v) => move(i, v)));",
3169
+ " if (linked)",
3170
+ " break;",
3171
+ " }",
3172
+ " stopGlide = () => stops.forEach((s) => s());",
3173
+ "}",
3079
3174
  "function fit() {",
3080
3175
  " const r = canvases[0].querySelector('svg').getBoundingClientRect();",
3081
3176
  " const k = Math.min(r.width / data.width, r.height / data.height, 1) || 1;",
@@ -3093,6 +3188,7 @@ var CLIENT_JS = [
3093
3188
  " const svg = canvas.querySelector('svg');",
3094
3189
  " canvas.addEventListener('wheel', (e) => {",
3095
3190
  " e.preventDefault();",
3191
+ " stopGlide();",
3096
3192
  " const t = ts[i];",
3097
3193
  " const r = svg.getBoundingClientRect();",
3098
3194
  " const px = e.clientX - r.left;",
@@ -3101,6 +3197,7 @@ var CLIENT_JS = [
3101
3197
  " move(i, { x: px - ((px - t.x) / t.k) * k, y: py - ((py - t.y) / t.k) * k, k });",
3102
3198
  " }, { passive: false });",
3103
3199
  " canvas.addEventListener('pointerdown', (e) => {",
3200
+ " stopGlide();",
3104
3201
  " drag = { i, x: e.clientX - ts[i].x, y: e.clientY - ts[i].y, sx: e.clientX, sy: e.clientY, canvas };",
3105
3202
  " moved = false;",
3106
3203
  " });",
@@ -3151,6 +3248,7 @@ var CLIENT_JS = [
3151
3248
  " panel.appendChild(tpl.content.cloneNode(true));",
3152
3249
  " }",
3153
3250
  " setInfo(!tpl);",
3251
+ " focusBtn.disabled = !tpl;",
3154
3252
  " review.paint();",
3155
3253
  " hunks.reset();",
3156
3254
  "}",
@@ -3197,6 +3295,7 @@ var CLIENT_JS = [
3197
3295
  " });",
3198
3296
  " backBtn.addEventListener('click', () => trail.back());",
3199
3297
  " forwardBtn.addEventListener('click', () => trail.forward());",
3298
+ " focusBtn.addEventListener('click', zoomToSelected);",
3200
3299
  " window.addEventListener('keydown', (e) => {",
3201
3300
  " if (!e.altKey || (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight'))",
3202
3301
  " return;",
@@ -3247,69 +3346,27 @@ var CLIENT_JS = [
3247
3346
  " setTheme(THEMES[(i + 1) % THEMES.length], true);",
3248
3347
  " });",
3249
3348
  "}",
3250
- "function initPanelResize() {",
3251
- " const aside = document.querySelector('aside');",
3252
- " const handle = document.getElementById('resize');",
3253
- " let width = 0;",
3254
- " const panes = !!document.getElementById('panes');",
3255
- " const widthKey = panes ? 'codechart.panel.panes' : 'codechart.panel';",
3256
- " const minWidth = panes ? 200 : 300;",
3257
- " const setWidth = (w, remember) => {",
3258
- " width = Math.round(Math.max(minWidth, Math.min(w, window.innerWidth * 0.8)));",
3259
- " aside.style.width = `${width}px`;",
3260
- " if (remember)",
3261
- " save(widthKey, String(width));",
3262
- " };",
3263
- " const currentWidth = () => width || aside.getBoundingClientRect().width;",
3264
- " const savedWidth = Number(load(widthKey));",
3265
- " if (savedWidth > 0)",
3266
- " setWidth(savedWidth, false);",
3267
- " let sizing = false;",
3268
- " handle.addEventListener('pointerdown', (e) => {",
3269
- " sizing = true;",
3270
- " handle.classList.add('drag');",
3271
- " if (handle.setPointerCapture)",
3272
- " handle.setPointerCapture(e.pointerId);",
3273
- " e.preventDefault();",
3274
- " });",
3275
- " handle.addEventListener('pointermove', (e) => {",
3276
- " if (sizing)",
3277
- " setWidth(window.innerWidth - e.clientX, false);",
3278
- " });",
3279
- " const endSize = () => {",
3280
- " if (!sizing)",
3281
- " return;",
3282
- " sizing = false;",
3283
- " handle.classList.remove('drag');",
3284
- " setWidth(currentWidth(), true);",
3285
- " };",
3286
- " handle.addEventListener('pointerup', endSize);",
3287
- " handle.addEventListener('pointercancel', endSize);",
3288
- " handle.addEventListener('keydown', (e) => {",
3289
- " const step = e.key === 'ArrowLeft' ? 40 : e.key === 'ArrowRight' ? -40 : 0;",
3290
- " if (!step)",
3291
- " return;",
3292
- " e.preventDefault();",
3293
- " setWidth(currentWidth() + step, true);",
3294
- " });",
3295
- "}",
3296
3349
  "initPanZoom();",
3297
3350
  "initPaneLink();",
3298
3351
  "initTheme();",
3299
- "initMode(panel);",
3300
3352
  "initPanelResize();",
3301
3353
  "window.addEventListener('resize', fit);",
3302
3354
  "fit();",
3303
3355
  "dismissFocus(canvases, () => moved);",
3304
3356
  "initChips();",
3305
3357
  "const review = initReview(data.repoKey, goTo);",
3306
- "const hunks = initHunks(panel, review);",
3358
+ "const hunks = initHunks(panel, review, zoomToSelected);",
3307
3359
  "initPanel();",
3308
3360
  "})();",
3309
3361
  ""
3310
3362
  ].join("\n");
3311
3363
 
3312
3364
  // src/render/web/page.ts
3365
+ var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
3366
+ function prettyDate(d) {
3367
+ const pad2 = (n) => String(n).padStart(2, "0");
3368
+ return `${d.getDate()} ${MONTHS[d.getMonth()]} ${d.getFullYear()}, ${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
3369
+ }
3313
3370
  function esc(s) {
3314
3371
  return stripInvisible(s).replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g, "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
3315
3372
  }
@@ -3341,7 +3398,7 @@ function midpoint(points) {
3341
3398
  return points[0] ?? { x: 0, y: 0 };
3342
3399
  }
3343
3400
  var keyHtml = (key) => key.map((k) => `<span class="k-${k.tone}">${esc(k.text)}</span>`).join(" \xB7 ");
3344
- var KEY_HELP = ["n / p: next / previous hunk (opens it, folds the others)", "] / [: next / previous unreviewed node", "r: toggle reviewed", "o / O: fold this hunk / toggle all hunks", "?: this help"];
3401
+ var KEY_HELP = ["n / p: next / previous hunk (opens it, folds the others)", "] / [: next / previous unreviewed node", "r: toggle reviewed", "o / O: fold this hunk / toggle all hunks", "f: zoom to the selected node", "?: this help"];
3345
3402
  var CSP = `default-src 'none'; style-src 'unsafe-inline'; script-src 'sha256-${createHash2("sha256").update(CLIENT_JS).digest("base64")}'; img-src data:; base-uri 'none'; form-action 'none'`;
3346
3403
  function renderPage(p) {
3347
3404
  const theme = p.meta.theme && THEMES.includes(p.meta.theme) ? p.meta.theme : "auto";
@@ -3351,19 +3408,19 @@ function renderPage(p) {
3351
3408
  <g class="viewport">${viewport3}</g></svg></div>`;
3352
3409
  const body = p.panes ? `<div id="panes">${p.panes.map((pane, i) => `<section class="pane" aria-label="${esc(pane.title)}"><div class="pane-title">${esc(pane.title)}<span class="pane-key"> \xB7 ${keyHtml(pane.key)}</span></div>${canvas(pane.viewport, i)}</section>`).join("")}</div>` : canvas(p.viewport, 0);
3353
3410
  return `<!doctype html>
3354
- <html lang="en" data-theme="${theme}" data-mode="${p.modes ? "light" : "full"}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
3411
+ <html lang="en" data-theme="${theme}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
3355
3412
  <meta http-equiv="Content-Security-Policy" content="${CSP}">
3356
3413
  <title>${esc(p.title)}</title>
3357
3414
  <style>${CSS}${p.extraCss ?? ""}</style></head>
3358
3415
  <body>
3359
- <header><h1>${esc(p.title)}</h1>${p.headerNote ?? ""}<span class="meta">${esc(p.meta.repo)} \xB7 ${esc(p.meta.generatedAt.toISOString())}</span>${p.meta.update ? `<span class="update" title="${esc(["A newer codechart is out", ...(p.meta.updateNotes ?? []).map((n) => `- ${n}`)].join("\n"))}">codechart ${esc(p.meta.update)} is out: run <code>codechart update</code></span>` : ""}${p.infoButton}${p.modes ? '<button id="mode-toggle" type="button" title="Light: short diffs. Full: whole diffs, review ticks and keys (n p ] [ r o ?)"></button>' : ""}${p.panes ? '<button id="link-toggle" type="button" title="Linked: panning or zooming one pane moves both"></button>' : ""}<button id="theme-toggle" type="button" title="Cycle theme: auto, light, dark"></button></header>
3416
+ <header><h1>${esc(p.title)}</h1>${p.headerNote ?? ""}<span class="meta">${esc(p.meta.repo)} \xB7 <time datetime="${p.meta.generatedAt.toISOString()}" title="${p.meta.generatedAt.toISOString()}">${prettyDate(p.meta.generatedAt)}</time></span>${p.meta.update ? `<span class="update" title="${esc(["A newer codechart is out", ...(p.meta.updateNotes ?? []).map((n) => `- ${n}`)].join("\n"))}">codechart ${esc(p.meta.update)} is out: run <code>codechart update</code></span>` : ""}${p.infoButton}${p.panes ? '<button id="link-toggle" type="button" title="Linked: panning or zooming one pane moves both"></button>' : ""}<button id="theme-toggle" type="button" title="Cycle theme: auto, light, dark"></button></header>
3360
3417
  ${p.toolbar ? `<div id="toolbar">${p.toolbar}</div>
3361
3418
  ` : ""}<main>
3362
3419
  ${body}
3363
3420
  <div id="resize" role="separator" aria-orientation="vertical" aria-label="Resize panel" tabindex="0" title="Drag to resize the panel"></div>
3364
- <aside><nav id="panel-nav" aria-label="Panel history"><button id="nav-back" type="button" disabled aria-label="Back" title="Back (Alt+\u2190)">\u2190</button><button id="nav-forward" type="button" disabled aria-label="Forward" title="Forward (Alt+\u2192)">\u2192</button></nav>${p.aside}</aside>
3421
+ <aside><nav id="panel-nav" aria-label="Panel history"><button id="nav-focus" type="button" disabled aria-label="Focus node (f)" title="Focus node (f)">\u25CE</button><button id="nav-back" type="button" disabled aria-label="Back" title="Back (Alt+\u2190)">\u2190</button><button id="nav-forward" type="button" disabled aria-label="Forward" title="Forward (Alt+\u2192)">\u2192</button></nav>${p.aside}</aside>
3365
3422
  </main>
3366
- <div id="key-help" role="dialog" aria-label="Keys" hidden><b>Keys (Full)</b>${KEY_HELP.map((k) => `<div>${esc(k)}</div>`).join("")}</div>
3423
+ <div id="key-help" role="dialog" aria-label="Keys" hidden><b>Keys</b>${KEY_HELP.map((k) => `<div>${esc(k)}</div>`).join("")}</div>
3367
3424
  <script type="application/json" id="spec-data">${jsonForScript(data)}</script>
3368
3425
  <script>${CLIENT_JS}</script>
3369
3426
  </body></html>
@@ -3459,16 +3516,16 @@ var LABEL_LINE_HEIGHT = 14;
3459
3516
  var LABEL_BREAKS = ["_", ".", "/", "-", " "];
3460
3517
  function labelLines(label) {
3461
3518
  if (label.length <= LABEL_CHARS) return [label];
3462
- const head = label.slice(0, LABEL_CHARS);
3463
- const camel = [...head.matchAll(/[a-z\d](?=[A-Z])/g)].map((m) => m.index);
3464
- const cut2 = Math.max(...LABEL_BREAKS.map((c) => head.lastIndexOf(c)), ...camel) + 1;
3519
+ const head2 = label.slice(0, LABEL_CHARS);
3520
+ const camel = [...head2.matchAll(/[a-z\d](?=[A-Z])/g)].map((m) => m.index);
3521
+ const cut2 = Math.max(...LABEL_BREAKS.map((c) => head2.lastIndexOf(c)), ...camel) + 1;
3465
3522
  const at = cut2 >= LABEL_CHARS / 2 ? cut2 : LABEL_CHARS;
3466
3523
  const rest = label.slice(at).trim();
3467
3524
  return [label.slice(0, at).trimEnd(), rest.length > LABEL_MORE_CHARS ? rest.slice(0, LABEL_MORE_CHARS - 1) + "\u2026" : rest];
3468
3525
  }
3469
3526
  var headerHeight = (label) => HEADER_HEIGHT + LABEL_LINE_HEIGHT * (labelLines(label).length - 1);
3470
- function nodeHeight(label, fields, summary2) {
3471
- const summaryLines = summary2 ? wrapSummary(summary2).length : 0;
3527
+ function nodeHeight(label, fields, summary) {
3528
+ const summaryLines = summary ? wrapSummary(summary).length : 0;
3472
3529
  return headerHeight(label) + LINE_HEIGHT * (fields + summaryLines);
3473
3530
  }
3474
3531
  var FIT_CANVASES = [
@@ -3626,7 +3683,7 @@ var flowObject = z3.strictObject({
3626
3683
  gaps: z3.array(long()).optional()
3627
3684
  });
3628
3685
  function flowFacts(spec) {
3629
- const counts = outgoingCounts(spec, spec.links);
3686
+ const counts2 = outgoingCounts(spec, spec.links);
3630
3687
  const live = outgoingLinks(spec, spec.links.map((l, i) => ({ ...l, i })));
3631
3688
  const byId = new Map(spec.steps.map((s) => [s.id, s]));
3632
3689
  const brandNew = (id) => byId.get(id)?.status === "planned" && !byId.get(id)?.source;
@@ -3646,7 +3703,7 @@ function flowFacts(spec) {
3646
3703
  brandNew,
3647
3704
  removedStep,
3648
3705
  existsNow,
3649
- typeOf: (step) => step.type ?? inferType(counts.get(step.id) ?? 0),
3706
+ typeOf: (step) => step.type ?? inferType(counts2.get(step.id) ?? 0),
3650
3707
  branchesNow: (id) => spec.kind === "plan" && (nowOut.get(id)?.length ?? 0) >= 2 && (live.get(id)?.length ?? 0) < 2
3651
3708
  };
3652
3709
  }
@@ -3751,8 +3808,8 @@ var flowSchema = flowObject.superRefine((spec, ctx) => {
3751
3808
  function validateFlowSpec(input) {
3752
3809
  const result = flowSchema.safeParse(input);
3753
3810
  if (!result.success) return { ok: false, errors: formatIssues(result.error) };
3754
- const counts = outgoingCounts(result.data, result.data.links);
3755
- const steps = result.data.steps.map((s) => ({ ...s, type: s.type ?? inferType(counts.get(s.id) ?? 0) }));
3811
+ const counts2 = outgoingCounts(result.data, result.data.links);
3812
+ const steps = result.data.steps.map((s) => ({ ...s, type: s.type ?? inferType(counts2.get(s.id) ?? 0) }));
3756
3813
  return { ok: true, spec: { ...result.data, diagram: "flow", steps } };
3757
3814
  }
3758
3815
  function flowJsonSchema() {
@@ -3796,12 +3853,12 @@ var CHIP_ORDER = ["new", "changed", "removed", "planned", "config", "context", "
3796
3853
  var CHIP_MARK = { new: "+", changed: "~", removed: "\u2212", planned: "\u25CB", config: "\u25C6", context: "\xB7", existing: "\xB7" };
3797
3854
  var UNCHANGED = ["context", "existing"];
3798
3855
  function statusChips(statuses) {
3799
- const counts = /* @__PURE__ */ new Map();
3800
- for (const s of statuses) counts.set(s, (counts.get(s) ?? 0) + 1);
3801
- const chips = CHIP_ORDER.filter((s) => counts.has(s)).map(
3802
- (s) => `<button type="button" class="chip chip-${s}" data-status="${s}" aria-pressed="false" title="Fade ${s} nodes">${CHIP_MARK[s]}${counts.get(s)} ${s}</button>`
3856
+ const counts2 = /* @__PURE__ */ new Map();
3857
+ for (const s of statuses) counts2.set(s, (counts2.get(s) ?? 0) + 1);
3858
+ const chips = CHIP_ORDER.filter((s) => counts2.has(s)).map(
3859
+ (s) => `<button type="button" class="chip chip-${s}" data-status="${s}" aria-pressed="false" title="Fade ${s} nodes">${CHIP_MARK[s]}${counts2.get(s)} ${s}</button>`
3803
3860
  );
3804
- const unchanged = UNCHANGED.find((s) => counts.has(s));
3861
+ const unchanged = UNCHANGED.find((s) => counts2.has(s));
3805
3862
  if (unchanged) {
3806
3863
  chips.unshift(
3807
3864
  `<button type="button" class="chip chip-delta" data-delta="${unchanged}" aria-pressed="false" title="Fade ${unchanged} nodes, leaving only the changes">\u0394 changes only</button>`
@@ -3809,10 +3866,10 @@ function statusChips(statuses) {
3809
3866
  }
3810
3867
  return chips.length ? `<div id="chips" role="group" aria-label="Status filter">${chips.join("")}</div>` : "";
3811
3868
  }
3812
- var reviewControls = (total) => `<div id="review" class="fo"><span id="review-count">0/${total} reviewed</span><span id="review-bar" aria-hidden="true"><i></i></span><button id="next-unreviewed" type="button" title="Next unreviewed: select the next node not ticked as reviewed" aria-label="Next unreviewed">Next \u25B8</button></div>`;
3869
+ var reviewControls = (total) => `<div id="review"><span id="review-count">0/${total} reviewed</span><span id="review-bar" aria-hidden="true"><i></i></span><button id="next-unreviewed" type="button" title="Next unreviewed: select the next node not ticked as reviewed" aria-label="Next unreviewed">Next \u25B8</button></div>`;
3813
3870
  var diffRev = (p) => p ? createHash3("sha256").update(JSON.stringify(p)).digest("hex").slice(0, 12) : void 0;
3814
- var tickSvg = (x, y) => `<g class="tick fo" aria-hidden="true"><rect class="tick-hit" x="${num(x - 9)}" y="${num(y - 9)}" width="18" height="18"/><rect class="tick-box" x="${num(x - 6)}" y="${num(y - 6)}" width="12" height="12" rx="2"/><path class="tick-mark" d="M${num(x - 3)},${num(y)} L${num(x - 1)},${num(y + 3)} L${num(x + 3.5)},${num(y - 3)}"/></g>`;
3815
- var tickRow = (id) => `<label class="tick-row fo"><input type="checkbox" data-tick-for="${esc(id)}"> Reviewed</label>`;
3871
+ var tickSvg = (x, y) => `<g class="tick" aria-hidden="true"><rect class="tick-hit" x="${num(x - 9)}" y="${num(y - 9)}" width="18" height="18"/><rect class="tick-box" x="${num(x - 6)}" y="${num(y - 6)}" width="12" height="12" rx="2"/><path class="tick-mark" d="M${num(x - 3)},${num(y)} L${num(x - 1)},${num(y + 3)} L${num(x + 3.5)},${num(y - 3)}"/></g>`;
3872
+ var panelTitle = (id, text) => `<h2 class="ptitle"><input type="checkbox" data-tick-for="${esc(id)}" aria-label="Reviewed"><span>${esc(text)}</span></h2>`;
3816
3873
  var note = (l) => l.label || (l.kind !== "other" ? l.kind : void 0);
3817
3874
  function relationsOf(id, links, labelOf2) {
3818
3875
  return links.flatMap((l) => {
@@ -3822,12 +3879,10 @@ function relationsOf(id, links, labelOf2) {
3822
3879
  return [{ out, id: other, label: labelOf2(other), ...note(l) ? { kind: note(l) } : {} }];
3823
3880
  });
3824
3881
  }
3882
+ var relList = (rels) => rels.length ? `<ul>${rels.map((r) => `<li><button type="button" class="rel" data-goto="${esc(r.id)}">${esc(r.label)}${r.kind ? ` (${esc(r.kind)})` : ""}</button></li>`).join("")}</ul>` : '<p class="rel-none">none</p>';
3825
3883
  function relationsHtml(rels) {
3826
3884
  if (!rels.length) return "";
3827
- const rows = rels.map(
3828
- (r) => `<li><button type="button" class="rel" data-goto="${esc(r.id)}">${r.out ? "\u2192" : "\u2190"} ${esc(r.label)}${r.kind ? ` (${esc(r.kind)})` : ""}</button></li>`
3829
- );
3830
- return `<h3>Relations</h3><ul class="relations">${rows.join("")}</ul>`;
3885
+ return `<h3>Relations</h3><div class="relations"><div class="rel-col"><h4>\u2190 Used by</h4>${relList(rels.filter((r) => !r.out))}</div><div class="rel-col"><h4>Uses \u2192</h4>${relList(rels.filter((r) => r.out))}</div></div>`;
3831
3886
  }
3832
3887
 
3833
3888
  // src/render/web/diagram.ts
@@ -3865,8 +3920,7 @@ function renderDiagramPage(p) {
3865
3920
  width: p.width,
3866
3921
  height: p.height,
3867
3922
  extraCss: p.extraCss,
3868
- extraDefs: p.extraDefs,
3869
- modes: p.modes
3923
+ extraDefs: p.extraDefs
3870
3924
  });
3871
3925
  }
3872
3926
 
@@ -3981,7 +4035,7 @@ var FLOW_CSS = `
3981
4035
  .node .shape{fill:var(--card);stroke:var(--muted);stroke-width:1.2}
3982
4036
  .node .label{font-weight:500;text-anchor:middle}
3983
4037
  .node .badge{text-anchor:middle;font-weight:600}
3984
- .node.selected .shape{stroke-width:2.5}
4038
+ .node.selected .shape{stroke-width:3}
3985
4039
  .node:focus-visible .shape{stroke:var(--edge);stroke-width:3.5}
3986
4040
  .status-new .shape{stroke:var(--new)}
3987
4041
  .status-changed .shape{stroke:var(--chg)}
@@ -4049,13 +4103,12 @@ var splitIndent = (code) => {
4049
4103
  const width = [...lead].reduce((w, c) => w + (c === " " ? TAB : 1), 0);
4050
4104
  return [width, lead ? `<span class="ind">${lead}</span>${rest}` : rest];
4051
4105
  };
4052
- var codeRow = (n, code, cls, extra = "", sign) => {
4053
- const both = (c) => c || extra ? ` class="${[c, extra].filter(Boolean).join(" ")}"` : "";
4106
+ var codeRow = (n, code, cls, sign) => {
4107
+ const cl = (c) => c ? ` class="${c}"` : "";
4054
4108
  const [indent, text] = n === void 0 ? [0, code] : splitIndent(code);
4055
4109
  const pad2 = indent ? ` style="padding-left:${indent}ch;text-indent:-${indent}ch"` : "";
4056
- const ln = `<span${both("ln")}>${n ?? ""}</span>`;
4057
- if (sign === void 0) return `${ln}<span${both(cls)}${pad2}>${text}</span>`;
4058
- return `${ln}<span${both(`${cls} dr`)}><span class="sg">${sign}</span><span class="cd"${pad2}>${text}</span></span>`;
4110
+ if (sign === void 0) return `<span class="ln">${n ?? ""}</span><span${cl(cls)}${pad2}>${text}</span>`;
4111
+ return `<span class="${cls} dr"><span class="ln">${n ?? ""}</span><span class="sg">${sign}</span><span class="cd"${pad2}>${text}</span></span>`;
4059
4112
  };
4060
4113
  function snippetHtml(s) {
4061
4114
  const code = s.lines.map((l, i) => codeRow(s.startLine + i, esc(l))).join("\n");
@@ -4066,7 +4119,7 @@ function snippetHtml(s) {
4066
4119
  }
4067
4120
  var tag = (status) => `<span class="tag tag-${esc(status)}">${esc(status)}</span>`;
4068
4121
  function stepPanel(spec, step, snippets, byId, check) {
4069
- let out = `<h2>${esc(step.label)}</h2>${tickRow(step.id)}`;
4122
+ let out = panelTitle(step.id, step.label);
4070
4123
  out += `<div class="status">${tag(step.status)} ${esc(step.type)}</div>`;
4071
4124
  out += mismatchNote(check, step.id);
4072
4125
  const snip = snippets.steps.get(step.id);
@@ -4138,12 +4191,9 @@ function renderFlowHtml(spec, layout, snippets, meta, check) {
4138
4191
  }
4139
4192
 
4140
4193
  // src/render/web/changes.ts
4141
- var LIGHT_HUNKS = 3;
4142
- var LIGHT_ROWS = 40;
4143
- var SMALL_LINES = 80;
4144
- var SMALL_HUNKS = 6;
4194
+ var GAP_MIN = 4;
4145
4195
  var MARK3 = { add: "+", del: "-", ctx: " " };
4146
- var HEADER = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@ ?(.*)$/;
4196
+ var HEADER = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@ ?(.*)$/;
4147
4197
  function hunksOf(lines) {
4148
4198
  const out = [];
4149
4199
  for (const l of lines) {
@@ -4152,39 +4202,68 @@ function hunksOf(lines) {
4152
4202
  }
4153
4203
  return out;
4154
4204
  }
4155
- var PAGER = '<div class="pager fo" role="group" aria-label="Hunks"><button type="button" class="pg-prev" aria-label="Previous hunk" title="Previous hunk (p)">\u2039</button><span class="pg-count" role="status" aria-label="{n} hunks">\u2013 / {n}</span><button type="button" class="pg-next" aria-label="Next hunk" title="Next hunk (n)">\u203A</button><button type="button" class="pg-all pg-expand" aria-label="Expand all" title="Expand all hunks">+ all</button><button type="button" class="pg-all pg-collapse" aria-label="Collapse all" title="Collapse all hunks">\u2212 all</button><button type="button" class="pg-keys" aria-label="Show keys" title="Keys">? keys</button></div>';
4156
- var count = (n) => `${n} changed line${n === 1 ? "" : "s"}`;
4157
- function summary(rows, folded) {
4158
- const [head, ...body] = rows;
4159
- const m = HEADER.exec(head.text);
4160
- const add = body.filter((l) => l.kind === "add").length;
4161
- const del = body.filter((l) => l.kind === "del").length;
4205
+ function headerOf(rows) {
4206
+ const m = HEADER.exec(rows[0].text);
4207
+ return m ? { start: Number(m[1]), count: m[2] === void 0 ? 1 : Number(m[2]), fn: m[3] ?? "" } : void 0;
4208
+ }
4209
+ var span2 = (h) => h.count === 0 ? [h.start + 1, h.start] : [h.start, h.start + h.count - 1];
4210
+ var PAGER = '<div class="pager" role="group" aria-label="Hunks"><button type="button" class="pg-prev" aria-label="Previous hunk" title="Previous hunk (p)">\u2039</button><span class="pg-count" role="status" aria-label="{n} hunks">\u2013 / {n}</span><button type="button" class="pg-next" aria-label="Next hunk" title="Next hunk (n)">\u203A</button><button type="button" class="pg-all pg-expand" aria-label="Expand all" title="Expand all hunks">+ all</button><button type="button" class="pg-all pg-collapse" aria-label="Collapse all" title="Collapse all hunks">\u2212 all</button><button type="button" class="pg-keys" aria-label="Show keys" title="Keys">? keys</button></div>';
4211
+ var plural2 = (n, what) => `${n} ${what}${n === 1 ? "" : "s"}`;
4212
+ var count = (n) => plural2(n, "changed line");
4213
+ var counts = (add, del, cls) => `<span class="${cls}"><span class="n-add">+${add}</span> <span class="n-del">\u2212${del}</span></span>`;
4214
+ var tally = (rows) => ({ add: rows.filter((l) => l.kind === "add").length, del: rows.filter((l) => l.kind === "del").length });
4215
+ function head(rows) {
4216
+ const h = headerOf(rows);
4217
+ const body = rows.slice(1);
4218
+ const { add, del } = tally(body);
4162
4219
  const first = body.find((l) => l.kind !== "ctx");
4163
- return `<button type="button" class="hunk-sum fo" aria-expanded="${!folded}"><span class="caret" aria-hidden="true"></span><span class="hs-stat"><span class="d-add">+${add}</span> <span class="d-del">\u2212${del}</span></span>` + (m ? `<span class="hs-ln">L${m[1]}</span>` : "") + (m?.[2] ? `<span class="hs-fn">${esc(m[2])}</span>` : "") + (first ? `<span class="hs-first">${esc(MARK3[first.kind] + first.text.trim())}</span>` : "") + `</button>`;
4220
+ return `<button type="button" class="hunk-sum hh" aria-expanded="false"><span class="caret" aria-hidden="true"></span>` + (h ? `<span class="hs-ln">L${h.start}</span>` : "") + (h?.fn ? `<span class="hs-fn">${esc(h.fn)}</span>` : "") + (first ? `<span class="hs-first">${esc(MARK3[first.kind] + first.text.trim())}</span>` : "") + `${counts(add, del, "hs-stat")}</button>`;
4221
+ }
4222
+ function outside(prev, cur) {
4223
+ if (!cur) return "";
4224
+ const n = span2(cur)[0] - (prev ? span2(prev)[1] : 0) - 1;
4225
+ if (n <= 0) return "";
4226
+ return `<div class="gap gap-out">\u22EF ${plural2(n, "line")} ${prev ? "not in the diff" : "above"}</div>`;
4227
+ }
4228
+ var rowsHtml = (rows) => rows.map((l) => codeRow(l.n, esc(l.text), `d-${l.kind}`, MARK3[l.kind])).join("\n");
4229
+ function bodyHtml(rows) {
4230
+ const out = [];
4231
+ let j = 1;
4232
+ while (j < rows.length) {
4233
+ let k = j;
4234
+ while (k < rows.length && rows[k].kind === "ctx") k++;
4235
+ if (k - j >= GAP_MIN) {
4236
+ out.push(
4237
+ `<span class="cgap"><button type="button" class="gap gap-run" aria-expanded="false">\u22EF ${plural2(k - j, "unchanged line")}</button><span class="gap-rows">${rowsHtml(rows.slice(j, k))}</span></span>`
4238
+ );
4239
+ j = k;
4240
+ } else {
4241
+ out.push(rowsHtml([rows[j]]));
4242
+ j++;
4243
+ }
4244
+ }
4245
+ return out.join("\n");
4246
+ }
4247
+ function totals(p) {
4248
+ const { add, del } = tally(p.lines);
4249
+ return p.rows > p.lines.length ? `<span class="fh-stat">${count(p.total)}</span>` : counts(add, del, "fh-stat");
4164
4250
  }
4165
- function changesHtml(p) {
4251
+ var samePath = (p, nodePath) => nodePath?.replace(/:\d+(?:-\d+)?$/, "").replace(/^\.\//, "") === p.path;
4252
+ function changesHtml(p, nodePath) {
4166
4253
  const title = "<h3>Changes</h3>";
4167
4254
  if (p.note) return `${title}<p class="more">${esc(p.note)}</p>`;
4168
4255
  const hunks = hunksOf(p.lines);
4169
4256
  const pager = hunks.length > 1 ? PAGER.replaceAll("{n}", String(hunks.length)) : "";
4170
- const folded = p.total > SMALL_LINES || hunks.length > SMALL_HUNKS;
4171
- let before = 0;
4172
- let lightChanged = 0;
4173
- const body = hunks.map((rows, i) => {
4174
- const start = before;
4175
- before += rows.length;
4176
- const inLight = (j) => i < LIGHT_HUNKS && start + j < LIGHT_ROWS;
4177
- const html = rows.map((l, j) => {
4178
- const fo = inLight(j) ? "" : "fo";
4179
- if (l.kind === "hunk") return codeRow(void 0, esc(l.text), "d-hunk", `lo ${fo}`.trim());
4180
- if (fo === "" && l.kind !== "ctx") lightChanged++;
4181
- return codeRow(l.n, esc(l.text), `d-${l.kind}`, fo, MARK3[l.kind]);
4182
- }).join("\n");
4183
- return `<div class="hunk${folded ? " folded" : ""}${inLight(0) ? "" : " fo"}">${summary(rows, folded)}<code class="hunk-body">${html}</code></div>`;
4257
+ let prev;
4258
+ const body = hunks.map((rows) => {
4259
+ const cur = headerOf(rows);
4260
+ const gap = outside(prev, cur);
4261
+ prev = cur;
4262
+ return `<div class="hunk folded">${gap}${head(rows)}<code class="hunk-body">${bodyHtml(rows)}</code></div>`;
4184
4263
  });
4185
- const light = lightChanged < p.total ? `<button type="button" class="see-full" data-mode-set="full">showing ${lightChanged} of ${p.total} changed lines \xB7 see all in Full</button>` : count(p.total);
4186
- const full = p.rows > p.lines.length ? `showing ${p.lines.length} of ${p.rows} lines` : count(p.total);
4187
- return `${title}${pager}<div class="file"><div class="file-head fo"><span class="path">${pathHtml(p.path)}</span><span>${count(p.total)}</span></div><div class="snippet diff">${body.join("")}</div></div><p class="more"><span class="lo">${light}</span><span class="fo">${full}</span> \xB7 whole file: <span class="path">${pathHtml(p.path)}</span></p>`;
4264
+ const file = samePath(p, nodePath) ? "" : `<div class="file-head"><span class="path">${pathHtml(p.path)}</span></div>`;
4265
+ const cut2 = p.rows > p.lines.length ? `<p class="more">showing ${p.lines.length} of ${p.rows} lines</p>` : "";
4266
+ return `<h3 class="ch-head">Changes${totals(p)}</h3>${pager}<div class="file">${file}<div class="snippet diff">${body.join("")}</div></div>${cut2}`;
4188
4267
  }
4189
4268
 
4190
4269
  // src/render/web/html.ts
@@ -4220,13 +4299,13 @@ var SHAPE2 = {
4220
4299
  other: "other"
4221
4300
  };
4222
4301
  var FOLD = 12;
4223
- function cardShape(shape2, { x, y, w, h }, head) {
4302
+ function cardShape(shape2, { x, y, w, h }, head2) {
4224
4303
  const r = x + w;
4225
4304
  if (shape2 === "file") {
4226
4305
  return `<path class="card" d="M${x},${y} H${r - FOLD} L${r},${y + FOLD} V${y + h} H${x} Z"/><path class="fold" d="M${r - FOLD},${y} V${y + FOLD} H${r}"/>`;
4227
4306
  }
4228
4307
  const card = `<rect class="card" x="${x}" y="${y}" width="${w}" height="${h}"${shape2 === "symbol" ? "" : ' rx="6"'}/>`;
4229
- return shape2 === "data" ? card + `<line class="head" x1="${x}" y1="${y + head - 3}" x2="${r}" y2="${y + head - 3}"/>` : card;
4308
+ return shape2 === "data" ? card + `<line class="head" x1="${x}" y1="${y + head2 - 3}" x2="${r}" y2="${y + head2 - 3}"/>` : card;
4230
4309
  }
4231
4310
  function renderNode(n, box, flag, fields, rev) {
4232
4311
  const flagged2 = flag !== "";
@@ -4234,8 +4313,8 @@ function renderNode(n, box, flag, fields, rev) {
4234
4313
  const y = Math.round(box.y * 10) / 10;
4235
4314
  const w = box.w;
4236
4315
  const lines = [];
4237
- const head = headerHeight(n.label);
4238
- let row = head;
4316
+ const head2 = headerHeight(n.label);
4317
+ let row = head2;
4239
4318
  const text = (cls, s) => {
4240
4319
  lines.push(`<text class="${cls}" x="${x + 8}" y="${y + row + 12}">${esc(s)}</text>`);
4241
4320
  row += 16;
@@ -4247,7 +4326,7 @@ function renderNode(n, box, flag, fields, rev) {
4247
4326
  const height = Math.max(row, Math.round(box.h * 10) / 10);
4248
4327
  const shape2 = SHAPE2[n.kind];
4249
4328
  const top = y + 18 + KIND_ROW;
4250
- return `<g class="node status-${n.status} shape-${shape2}" data-id="${esc(n.id)}" data-status="${n.status}"${rev ? ` data-rev="${rev}"` : ""} tabindex="0" role="button" aria-label="${esc(`${n.label} (${nodeWhat(n)}${flagged2 ? ", doesn't match the code" : ""})`)}">` + flag + cardShape(shape2, { x, y, w, h: height }, head) + `<line class="head" x1="${x}" y1="${y + head}" x2="${x + w}" y2="${y + head}"/>` + (n.kind === "other" ? "" : `<text class="kind" x="${x + 8}" y="${y + 12}">${n.kind}</text>`) + labelLines(n.label).map((l, i) => `<text class="label" x="${x + 8}" y="${top + i * LABEL_LINE_HEIGHT}">${esc(l)}</text>`).join("") + `<text class="badge" x="${x + w - 8}" y="${top}">${esc(n.status)}</text>` + lines.join("") + tickSvg(x, y) + (flagged2 ? flagMark(shape2 === "file" ? x + w - FOLD - 6 : x + w, y) : "") + `</g>`;
4329
+ return `<g class="node status-${n.status} shape-${shape2}" data-id="${esc(n.id)}" data-status="${n.status}"${rev ? ` data-rev="${rev}"` : ""} tabindex="0" role="button" aria-label="${esc(`${n.label} (${nodeWhat(n)}${flagged2 ? ", doesn't match the code" : ""})`)}">` + flag + cardShape(shape2, { x, y, w, h: height }, head2) + `<line class="head" x1="${x}" y1="${y + head2}" x2="${x + w}" y2="${y + head2}"/>` + (n.kind === "other" ? "" : `<text class="kind" x="${x + 8}" y="${y + 12}">${n.kind}</text>`) + labelLines(n.label).map((l, i) => `<text class="label" x="${x + 8}" y="${top + i * LABEL_LINE_HEIGHT}">${esc(l)}</text>`).join("") + `<text class="badge" x="${x + w - 8}" y="${top}">${esc(n.status)}</text>` + lines.join("") + tickSvg(x, y) + (flagged2 ? flagMark(shape2 === "file" ? x + w - FOLD - 6 : x + w, y) : "") + `</g>`;
4251
4330
  }
4252
4331
  var FIELDS_NOTE = "Only the fields the agent saw are listed. Set <code>defaults.context: full</code> in <code>.codechart.yaml</code> to let it read the full definition.";
4253
4332
  var fieldList = (fields) => `<ul>${fields.map((f) => `<li${f.change ? ` class="field-${f.change}-t"` : ""}>${esc(fieldText(f))}</li>`).join("")}</ul>`;
@@ -4259,14 +4338,14 @@ function fieldsHtml(n, sides2) {
4259
4338
  return `<h3>Fields now</h3>${fieldList(now)}<h3>Fields after</h3>${fieldList(after)}`;
4260
4339
  }
4261
4340
  function cardPanel(spec, n, check, previews, sides2) {
4262
- let out = `<h2>${esc(`${n.label} (${nodeWhat(n)})`)}</h2>${tickRow(n.id)}`;
4341
+ let out = panelTitle(n.id, `${n.label} (${nodeWhat(n)})`);
4263
4342
  out += mismatchNote(check, n.id);
4264
4343
  const match = check?.matches.get(n.id);
4265
4344
  if (match) out += snippetHtml(match);
4266
4345
  else if (n.path) out += `<div class="path">${pathHtml(n.path)}</div>`;
4267
4346
  if (n.summary) out += `<p>${esc(n.summary)}</p>`;
4268
4347
  const preview = previews?.get(n.id);
4269
- if (preview) out += changesHtml(preview);
4348
+ if (preview) out += changesHtml(preview, n.path);
4270
4349
  if (n.fields?.length) {
4271
4350
  out += fieldsHtml(n, sides2);
4272
4351
  if (n.fieldsComplete === false) out += `<p class="fields-note">${FIELDS_NOTE}</p>`;
@@ -4321,8 +4400,7 @@ function renderHtml(spec, layout, meta, check, previews) {
4321
4400
  aside: `${pageInfo2(spec, check, sides2)}<div id="panel" hidden></div>${spec.nodes.map((n) => cardPanel(spec, n, check, previews, sides2)).join("")}`,
4322
4401
  width: layout.width,
4323
4402
  height: layout.height,
4324
- extraDefs: CHANGE_ARROWS,
4325
- modes: Boolean(previews?.size)
4403
+ extraDefs: CHANGE_ARROWS
4326
4404
  });
4327
4405
  }
4328
4406
 
@@ -4355,14 +4433,14 @@ function checkLines(spec, check) {
4355
4433
  return lines;
4356
4434
  }
4357
4435
  function nodeDetail(n, check) {
4358
- const head = `- **${nodeName(n)}** \xB7 ${nodeWhat(n)}${n.path ? ` \xB7 \`${n.path.replace(/`/g, "")}\`` : ""}`;
4436
+ const head2 = `- **${nodeName(n)}** \xB7 ${nodeWhat(n)}${n.path ? ` \xB7 \`${n.path.replace(/`/g, "")}\`` : ""}`;
4359
4437
  const lines = [];
4360
4438
  const m = check?.mismatches.find((x) => x.id === n.id);
4361
4439
  if (m) lines.push(`\u2717 ${md(m.detail)}`);
4362
4440
  if (n.summary) lines.push(md(n.summary));
4363
4441
  if (n.fields?.length) lines.push(`Fields: ${n.fields.map((f) => md(fieldText(f))).join(" \xB7 ")}${n.fieldsComplete === false ? " (only the ones the agent saw)" : ""}`);
4364
4442
  for (const note2 of n.notes ?? []) lines.push(`Note: ${md(note2)}`);
4365
- return [head, ...lines.map((l) => ` - ${l}`)].join("\n");
4443
+ return [head2, ...lines.map((l) => ` - ${l}`)].join("\n");
4366
4444
  }
4367
4445
  var MAX_FILES2 = 8;
4368
4446
  var fileList = (files) => {
@@ -4380,14 +4458,14 @@ ${JSON.stringify(spec).replace(/</g, "\\u003c").replace(/>/g, "\\u003e")}
4380
4458
  var imageHref = (url) => encodeURI(url).replace(/[()]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
4381
4459
  function prBlock(spec, check, imageUrl) {
4382
4460
  const count2 = (s) => spec.nodes.filter((n) => n.status === s).length;
4383
- const counts = [`${spec.nodes.length} nodes`, `${count2("new")} new`, `${count2("changed")} changed`, ...count2("removed") ? [`${count2("removed")} removed`] : []].join(" \xB7 ");
4461
+ const counts2 = [`${spec.nodes.length} nodes`, `${count2("new")} new`, `${count2("changed")} changed`, ...count2("removed") ? [`${count2("removed")} removed`] : []].join(" \xB7 ");
4384
4462
  const url = imageHref(imageUrl);
4385
4463
  const nodes = [...spec.nodes].sort((a, b) => STATUS_ORDER.indexOf(a.status) - STATUS_ORDER.indexOf(b.status));
4386
4464
  const parts = [
4387
4465
  BLOCK_START,
4388
4466
  `<details><summary>Map: ${esc(flat(spec.title))}</summary>`,
4389
4467
  "",
4390
- [counts, checkHeadline(check)].filter(Boolean).join(" \xB7 "),
4468
+ [counts2, checkHeadline(check)].filter(Boolean).join(" \xB7 "),
4391
4469
  "",
4392
4470
  `[![${md(spec.title)}](${url})](${url})`
4393
4471
  ];
@@ -4648,8 +4726,8 @@ function present2(c, path3) {
4648
4726
  }
4649
4727
  function withCwd(c, path3, get, missing) {
4650
4728
  const direct = get(path3);
4651
- const outside = !isAbsolute3(path3) && escapes(relative2(c.root, resolve5(c.root, path3)));
4652
- if (c.cwd && (missing(direct) || outside)) {
4729
+ const outside2 = !isAbsolute3(path3) && escapes(relative2(c.root, resolve5(c.root, path3)));
4730
+ if (c.cwd && (missing(direct) || outside2)) {
4653
4731
  const rel = relative2(c.root, resolve5(c.cwd, path3));
4654
4732
  if (rel !== "" && !escapes(rel)) {
4655
4733
  const alt = rel.split(sep3).join("/");
@@ -4814,8 +4892,8 @@ var shownFields = (node) => {
4814
4892
  return [];
4815
4893
  };
4816
4894
  var fieldItem = (f) => flat(`${f.change ? FIELD_MARK2[f.change] : ""}${f.name}${f.was !== void 0 ? ` ${f.was} \u2192 ${f.type ?? "?"}` : f.type ? ` ${f.type}` : ""}`);
4817
- function arrowLines(head, links, byId, { width, color, cuts }) {
4818
- const indent = columns(head.text) + 1;
4895
+ function arrowLines(head2, links, byId, { width, color, cuts }) {
4896
+ const indent = columns(head2.text) + 1;
4819
4897
  const labels = links.map((e) => `${e.change ? EDGE_MARK[e.change] : ""}${flat(e.label ?? "")}`);
4820
4898
  const targets = links.map((e) => byId.get(e.to));
4821
4899
  const longest = Math.max(...labels.map(columns));
@@ -4828,7 +4906,7 @@ function arrowLines(head, links, byId, { width, color, cuts }) {
4828
4906
  const target = targets[i];
4829
4907
  return fit(
4830
4908
  [
4831
- i === 0 ? head : { text: " ".repeat(columns(head.text)) },
4909
+ i === 0 ? head2 : { text: " ".repeat(columns(head2.text)) },
4832
4910
  { text: ` ${arrow} ` },
4833
4911
  { text: truncate(kindLabel(target), width - indent - 4 - col, cuts), paint: color ? (s) => paint(target, s) : void 0 }
4834
4912
  ],
@@ -4841,8 +4919,8 @@ function blockLines(node, links, fields, byId, ctx) {
4841
4919
  const { width, color, cuts } = ctx;
4842
4920
  const cap = links.length > 0 ? Math.floor(width / 3) : width - columns(gutter(node.status));
4843
4921
  const text = `${gutter(node.status)}${truncate(kindLabel(node), cap, cuts)}`;
4844
- const head = { text, paint: color ? (s) => paint(node, s) : void 0 };
4845
- const lines = links.length > 0 ? arrowLines(head, links, byId, ctx) : [head.paint ? head.paint(text) : text];
4922
+ const head2 = { text, paint: color ? (s) => paint(node, s) : void 0 };
4923
+ const lines = links.length > 0 ? arrowLines(head2, links, byId, ctx) : [head2.paint ? head2.paint(text) : text];
4846
4924
  if (fields.length > 0) lines.push(wrapItems(DETAIL, fields.map(fieldItem), width));
4847
4925
  return lines;
4848
4926
  }
@@ -5008,17 +5086,17 @@ function walkFlow(spec, budget) {
5008
5086
  return shared.has(to) ? { items: [ref(step)] } : chain(step, false);
5009
5087
  };
5010
5088
  const start = byId.get(spec.start);
5011
- let head;
5089
+ let head2;
5012
5090
  if (shared.has(start.id)) {
5013
5091
  if (!take(start.id)) return { blocks: [], unreachable: 0, truncated: true };
5014
5092
  queue.push(start.id);
5015
- head = { shared: true, chain: chain(start, true) };
5093
+ head2 = { shared: true, chain: chain(start, true) };
5016
5094
  } else {
5017
- head = { shared: false, chain: chain(start, false) };
5095
+ head2 = { shared: false, chain: chain(start, false) };
5018
5096
  }
5019
- if (head.chain.items.some((i) => i.kind === "cut")) return { blocks: [], unreachable: 0, truncated: true };
5020
- const blocks2 = [head];
5021
- for (let i = head.shared ? 1 : 0; i < queue.length; i++) {
5097
+ if (head2.chain.items.some((i) => i.kind === "cut")) return { blocks: [], unreachable: 0, truncated: true };
5098
+ const blocks2 = [head2];
5099
+ for (let i = head2.shared ? 1 : 0; i < queue.length; i++) {
5022
5100
  blocks2.push({ shared: true, chain: chain(byId.get(queue[i]), true) });
5023
5101
  }
5024
5102
  const unreachable = spec.steps.filter((s) => !seen.has(s.id)).length;
@@ -5078,13 +5156,13 @@ function armLines(arms, rest, ctx) {
5078
5156
  const last = i === arms.length - 1;
5079
5157
  const glyph = last ? "\u2514\u2500 " : "\u251C\u2500 ";
5080
5158
  const label = truncate(labels[i], pad2, ctx.cuts);
5081
- const head = [{ text: rest + glyph }];
5159
+ const head2 = [{ text: rest + glyph }];
5082
5160
  if (pad2 > 0) {
5083
5161
  const paint2 = tones[i] ? painter(tones[i], ctx) : void 0;
5084
- head.push({ text: label, paint: paint2 }, { text: `${" ".repeat(pad2 - columns(label))} \u2192 ` });
5162
+ head2.push({ text: label, paint: paint2 }, { text: `${" ".repeat(pad2 - columns(label))} \u2192 ` });
5085
5163
  }
5086
5164
  const under2 = `${rest}${last ? " " : "\u2502 "}${pad2 > 0 ? " ".repeat(pad2 + 3) : ""}`;
5087
- return chainLines(arm.chain, head, under2, "", ctx);
5165
+ return chainLines(arm.chain, head2, under2, "", ctx);
5088
5166
  });
5089
5167
  }
5090
5168
  function chainLines(chain, first, rest, lead, ctx) {
@@ -5095,9 +5173,9 @@ function chainLines(chain, first, rest, lead, ctx) {
5095
5173
  prefix = [{ text: rest }];
5096
5174
  }
5097
5175
  if (chain.branch) {
5098
- const { head, arms } = chain.branch;
5099
- const glyph = head.type === "decision" ? "\u25C7 " : "";
5100
- lines.push(fit([...prefix, { text: glyph }, stepSegment(head, ctx)], ctx.width, ctx.cuts));
5176
+ const { head: head2, arms } = chain.branch;
5177
+ const glyph = head2.type === "decision" ? "\u25C7 " : "";
5178
+ lines.push(fit([...prefix, { text: glyph }, stepSegment(head2, ctx)], ctx.width, ctx.cuts));
5101
5179
  lines.push(...armLines(arms, rest, ctx));
5102
5180
  }
5103
5181
  return lines;
@@ -5137,12 +5215,12 @@ function renderFlowTree(spec, opts) {
5137
5215
  const md2 = opts.md ?? false;
5138
5216
  const alert = alertLine(opts.check, ctx.width);
5139
5217
  if (walk.blocks.length === 0) {
5140
- const head = webAlert(opts.check, ctx.width);
5141
- const body = (line) => head ? `${head}
5218
+ const head2 = webAlert(opts.check, ctx.width);
5219
+ const body = (line) => head2 ? `${head2}
5142
5220
  ${line}` : line;
5143
5221
  if (!opts.htmlPath) return { text: md2 ? flowMarkdown(spec.title, body(TOO_LARGE), ctx, flowKey(spec)) : `${body(TOO_LARGE)}
5144
5222
  `, truncated: true };
5145
- const text2 = md2 ? flowMarkdown(spec.title, head || void 0, ctx, flowKey(spec)) : `${body(fullMapLine(opts.htmlPath))}
5223
+ const text2 = md2 ? flowMarkdown(spec.title, head2 || void 0, ctx, flowKey(spec)) : `${body(fullMapLine(opts.htmlPath))}
5146
5224
  `;
5147
5225
  return { text: text2, truncated: true };
5148
5226
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codechart",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Agent skill + CLI: maps and flowcharts of code changes for AI coding agents, in terminal, chat and HTML",
5
5
  "keywords": [
6
6
  "agent-skills",