@hansenexus/hud 0.6.0 → 0.8.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.
Files changed (102) hide show
  1. package/README.md +172 -25
  2. package/dist/{a11y-B5DUaiCs.js → a11y-BGWw4jBr.js} +14 -2
  3. package/dist/{a11y-panel-p_t4eD7p.js → a11y-panel-DcfXnPHk.js} +1 -1
  4. package/dist/{access-D_ewAEJG.d.ts → access-CwPCPsv0.d.ts} +1 -1
  5. package/dist/{access-panel-CEfTr9ZI.js → access-panel-grAsMEDk.js} +1 -1
  6. package/dist/auto/runtime.d.ts +9 -9
  7. package/dist/auto.d.ts +2 -2
  8. package/dist/auto.js +5 -5
  9. package/dist/cli.js +34 -1
  10. package/dist/{data-panel-BmcHCQnM.js → data-panel-B6WPNmV6.js} +1 -1
  11. package/dist/{data-store-ChF1td_P.js → data-store-FNTQKMkG.js} +1 -1
  12. package/dist/{define-hud-CHPedaQ5.d.ts → define-hud-B0aFXrcK.d.ts} +15 -5
  13. package/dist/{design-D0kGgPoP.js → design-BIXY1-Ex.js} +45 -11
  14. package/dist/{dispatch-panel-B-xr_Giy.js → dispatch-panel-BDHgMhOk.js} +1 -1
  15. package/dist/{force-state-panel-_otVYh9i.js → force-state-panel-D5oDydLs.js} +1 -1
  16. package/dist/{handler-BpVhxEmU.js → handler-BKzaOhlJ.js} +1 -1
  17. package/dist/{handler-DtYVCZY6.d.ts → handler-BmFhaA2D.d.ts} +1 -1
  18. package/dist/icons-ByDyNq_E.js +71 -0
  19. package/dist/index-5B7foZut.d.ts +116 -0
  20. package/dist/{index-ReFbhQ9p.d.ts → index-B2KCKkN0.d.ts} +5 -0
  21. package/dist/index-B7qaEUgh.d.ts +44 -0
  22. package/dist/{index-DcH9V3cU.d.ts → index-BGFyuJyN.d.ts} +3 -0
  23. package/dist/{index-Hhh7OXzU.d.ts → index-BeqWehuh.d.ts} +44 -10
  24. package/dist/{index-DstI_ike.d.ts → index-BqKysxTq.d.ts} +5 -1
  25. package/dist/{index-DqOyNf1u.d.ts → index-D97Fnoie.d.ts} +4 -2
  26. package/dist/{index-CwfX-W87.d.ts → index-DS0yT0c-.d.ts} +3 -0
  27. package/dist/{index-BAV_1W8a.d.ts → index-DvlCkGB1.d.ts} +3 -1
  28. package/dist/index.d.ts +4 -4
  29. package/dist/index.js +1226 -256
  30. package/dist/{inspect-C9Ft8fqn.js → inspect-CSkm8tn3.js} +14 -2
  31. package/dist/{inspect-root-BkaupBMp.js → inspect-root-CmiFX0e5.js} +1 -1
  32. package/dist/navigation-CX6AXm7H.js +176 -0
  33. package/dist/next.d.ts +4 -1
  34. package/dist/next.js +12 -1
  35. package/dist/{observe-CdDnDBRP.js → observe-CBNLU148.js} +12 -2
  36. package/dist/{observe-panel-Cgp1M8oT.js → observe-panel-zU5LD-U9.js} +1 -1
  37. package/dist/obstacles-CCmRFTcZ.js +176 -0
  38. package/dist/{ops-panel-CEqDe_UT.js → ops-panel-DHhAnChL.js} +1 -1
  39. package/dist/plugins/a11y.d.ts +1 -1
  40. package/dist/plugins/a11y.js +1 -1
  41. package/dist/plugins/access/server.d.ts +3 -3
  42. package/dist/plugins/access/server.js +1 -1
  43. package/dist/plugins/access.d.ts +5 -2
  44. package/dist/plugins/access.js +18 -5
  45. package/dist/plugins/agent/server.js +2 -2
  46. package/dist/plugins/agent.d.ts +4 -2
  47. package/dist/plugins/agent.js +6 -3
  48. package/dist/plugins/capture/server.js +1 -1
  49. package/dist/plugins/capture.d.ts +2 -2
  50. package/dist/plugins/capture.js +1 -1
  51. package/dist/plugins/data/server.d.ts +1 -1
  52. package/dist/plugins/data/server.js +2 -2
  53. package/dist/plugins/data.d.ts +1 -1
  54. package/dist/plugins/data.js +30 -9
  55. package/dist/plugins/design/server.d.ts +55 -15
  56. package/dist/plugins/design/server.js +188 -123
  57. package/dist/plugins/design.d.ts +3 -3
  58. package/dist/plugins/design.js +1 -1
  59. package/dist/plugins/inspect.d.ts +1 -1
  60. package/dist/plugins/inspect.js +1 -1
  61. package/dist/plugins/observe.d.ts +1 -1
  62. package/dist/plugins/observe.js +1 -1
  63. package/dist/plugins/ops/server.d.ts +1 -1
  64. package/dist/plugins/ops/server.js +1 -1
  65. package/dist/plugins/ops.d.ts +5 -1
  66. package/dist/plugins/ops.js +16 -4
  67. package/dist/plugins/routes/server.d.ts +1 -1
  68. package/dist/plugins/routes/server.js +1 -1
  69. package/dist/plugins/routes.d.ts +3 -3
  70. package/dist/plugins/routes.js +384 -53
  71. package/dist/plugins/seo.d.ts +1 -1
  72. package/dist/plugins/seo.js +1 -1
  73. package/dist/plugins/vitals.d.ts +1 -1
  74. package/dist/plugins/vitals.js +9 -1
  75. package/dist/{plugins-DVy_vaYr.js → plugins-CcW_K7c2.js} +9 -1
  76. package/dist/{plugins-BZvDqGx5.d.ts → plugins-pL2CoWzI.d.ts} +39 -3
  77. package/dist/{poll-CjKsWZi8.js → poll-Dm0OijM4.js} +1 -1
  78. package/dist/same-origin-BHuZO1_H.js +36 -0
  79. package/dist/{seo-Dq9q_QkO.js → seo-BnnGq_vj.js} +13 -2
  80. package/dist/{seo-panel-CfiY-TnT.js → seo-panel-BThx56KM.js} +1 -1
  81. package/dist/server.d.ts +2 -2
  82. package/dist/server.js +2 -2
  83. package/dist/{sessions-panel-COvhPAzv.js → sessions-panel-MknKsTge.js} +1 -1
  84. package/dist/store.d.ts +1 -1
  85. package/dist/store.js +2 -2
  86. package/dist/{meta-C_G7MB5w.d.ts → types-Dc6JWZR7.d.ts} +6 -6
  87. package/dist/{unlock-store-4V3vR4Eg.js → unlock-store-CrGXQx1V.js} +1 -1
  88. package/dist/variant-bar-BzZ0ln-C.js +768 -0
  89. package/dist/variant-picks-Byc0hC8a.js +144 -0
  90. package/dist/variants-export-vEtZ-OGC.js +75 -0
  91. package/dist/{variants-panel-BDoSkwBJ.js → variants-panel-D23v5KIp.js} +72 -55
  92. package/dist/variants-types-BOsZ5fDz.js +65 -0
  93. package/dist/variants-types-VkW7vFZF.d.ts +139 -0
  94. package/dist/variants.d.ts +1 -1
  95. package/dist/variants.js +1 -1
  96. package/dist/vite.d.ts +2 -2
  97. package/dist/vite.js +1 -1
  98. package/package.json +1 -1
  99. package/dist/index-BnQ0dTZf.d.ts +0 -19
  100. package/dist/index-gCZBO53s.d.ts +0 -73
  101. package/dist/same-origin-BGet22CC.js +0 -21
  102. package/dist/variants-types-CcRf119M.d.ts +0 -63
package/README.md CHANGED
@@ -67,8 +67,11 @@ export const HudLoader = createHudLoader(
67
67
  );
68
68
  ```
69
69
 
70
- Render `<HudLoader />` in the root layout. Plugin routes mount through one catch-all route, fed
71
- the plugins' server halves:
70
+ Render `<HudLoader />` in the root layout. When the HUD's chunk does not load (a stale dev server, a
71
+ syntax error in `hud.tsx`), it renders nothing and warns once in the console; the page is
72
+ unaffected. The HUD then docks as an icon rail on the right edge,
73
+ as its DEV chip until clicked (see [Dock](#dock-rail-and-pill)). Plugin routes mount through
74
+ one catch-all route, fed the plugins' server halves:
72
75
 
73
76
  ```ts
74
77
  // src/app/api/hud/[...hud]/route.ts
@@ -279,8 +282,8 @@ In the playground, `?env=staging` runs this flow with the password `playground`.
279
282
 
280
283
  ## Write a plugin
281
284
 
282
- A plugin is `{ id, title?, capability?, panel?, pill?, pillPriority?, commands?, routes? }`, shipped as two
283
- halves with the same `id`: the client half (`panel`, `pill`, `commands`) and the server half
285
+ A plugin is `{ id, title?, capability?, icon?, badge?, panel?, overlay?, pill?, pillPriority?, commands?, routes? }`,
286
+ shipped as two halves with the same `id`: the client half (`panel`, `overlay`, `pill`, `icon`, `badge`, `commands`) and the server half
284
287
  (`routes`), so route code never reaches a client bundle. The panel is a plain React component
285
288
  receiving `ctx`. Make it a dynamic import, so its code loads on first open and the pill stays
286
289
  light; the shell shows "Loading…" meanwhile and contains a panel that fails to load or throws:
@@ -305,22 +308,75 @@ follows this split, see [Bundle budget](#bundle-budget).
305
308
  | `open()` | open the panel |
306
309
  | `grab` | the element grabber: `start()`, `cancel()`, `clear()`, `amend(patch)`, `highlight(el, label)`, `clearHighlight()`; read it with `useGrab(ctx.grab)` |
307
310
 
311
+ On the rail a plugin shows as an icon with a status badge. `icon` is any 24×24 SVG component;
312
+ `hudIcon("database")` picks one of the built-in lucide shapes (`bug`, `database`, `git-branch`,
313
+ `send`, `terminal`, `palette`, `layers`, `toggle`, `crosshair`, `gauge`, `lock`, `search`,
314
+ `accessibility`, `activity`, `route`, `plug`, …; `HUD_ICON_NAMES` lists them), rendered from one
315
+ sprite, so no icon library ships. Without an icon the rail shows a plug. `badge` is called like a
316
+ component (hooks allowed) and returns `{ tone: "good" | "warn" | "poor" | "off", count? }` or
317
+ `null`: a dot in that tone, or a count bubble. `ratingTone()` maps a `.dot[data-rating]` rating.
318
+ `pill` keeps working unchanged as the tooltip text, so a plugin written for the pill needs no
319
+ change:
320
+
321
+ ```tsx
322
+ definePlugin({
323
+ id: "data",
324
+ title: "Data",
325
+ icon: hudIcon("database"),
326
+ badge: () => (useMode() === "mock" ? { tone: "warn" } : { tone: "good" }),
327
+ pill: () => <>{useMode()}</>,
328
+ });
329
+ ```
330
+
331
+ `overlay` is a component on the page itself, next to the dock, for as long as the HUD is mounted
332
+ (the variant bar is one). It places itself and sets `pointer-events: auto` on what takes input; one
333
+ that fails to load or throws renders nothing. Keep it a dynamic import too.
334
+
308
335
  Routes are keyed by path, then method: `routes: { "/runs/:id": { GET: (req, { params }) => ... } }`.
309
336
  An unknown path answers 404, a known path with another method 405.
310
337
 
311
338
  `playground/src/plugins/server-info` is a working example: the playground serves its routes
312
339
  through MSW with the same `createHudHandler` an app mounts.
313
340
 
314
- ## Pill
315
-
316
- - The pill starts bottom-left. It scans the page for `position: fixed` and `sticky` elements
317
- (cookie banners, chat launchers, booking CTAs, sticky navs) and takes the first corner none of
318
- them covers; when every corner is covered, it shifts off the edge that needs the smallest move,
319
- bottom corners preferred. Backdrops covering more than half the viewport are ignored.
341
+ ## Dock: rail and pill
342
+
343
+ The HUD docks as a vertical **edge rail** by default: one icon per plugin stacked on the right
344
+ edge, status as a badge on the icon (a dot in good/warn/poor/off, or a count), the plugin's title
345
+ and its live `pill` text in a tooltip beside the rail. Dark graphite chrome whatever the OS theme;
346
+ the panels keep following it. The rail reserves no page space and never crosses the content column.
347
+
348
+ - Three **detail levels**, cycled by the DEV chip and `⌘⇧D` (Ctrl+Shift+D elsewhere, `hud.detail`):
349
+ the chip alone with three summary dots (the badges of the three highest-priority plugins:
350
+ `access` 30, `observe` (errors) 20, `ops` (CI) 10, then rail order), the icon strip with tooltips,
351
+ and the labelled strip with title and live pill text per row. At the strip levels the rail runs
352
+ flat down the whole edge, square, no shadow, in three sections: the chip at the top edge, the
353
+ plugin rows aligned under it (they scroll when the window is short), the tools (Grab element,
354
+ `⋯`) at the bottom edge, on either side. Tooltips and the `⋯` menu share the look: tinted
355
+ section heads behind hairlines. The level is kept per `appSlug`; the first load is the chip.
356
+ - On a page that scrolls under an overlay scrollbar (macOS, mobile) the right-docked rail keeps a
357
+ 12 px lane free at the edge, so the thumb never paints over an icon or badge. A classic scrollbar
358
+ has its own gutter, and the rail sits inside it.
359
+ - **Customise rail** (`⋯` menu): every row shows a grip to drag it into place, arrows, and a switch
360
+ that takes it off the rail. Hidden plugins keep running and stay one menu entry away. Order and
361
+ hidden rows are kept per app; `Reset layout` forgets them.
362
+ - **Side**: `⋯ → Dock left / Dock right`, or drag the chip past the middle of the window. Kept per
363
+ app; panels open beside the rail on its side. `⋯ → Reset layout` forgets it.
364
+ - The rows sit centred on the edge and move up or down off the host's `position: fixed` and
365
+ `sticky` elements (cookie banners, chat launchers, booking CTAs), scored like the pill's shift.
366
+ - Below 900 px the rail is one 44 px round button bottom-right with a count badge; a tap opens a
367
+ two-column sheet of every plugin above it. Panels still open as the bottom sheet below 768 px.
368
+ - `prefers-reduced-motion` turns the level and tooltip transitions off.
369
+
370
+ `defineHud({ dock: "pill" })` (or `dock` on the mounted component) brings back the horizontal
371
+ **corner pill**:
372
+
373
+ - The pill starts bottom-left. It scans the page for `position: fixed` and `sticky` elements and
374
+ takes the first corner none of them covers; when every corner is covered, it shifts off the edge
375
+ that needs the smallest move, bottom corners preferred. Backdrops covering more than half the
376
+ viewport are ignored.
320
377
  - When the pill is wider than the viewport, items move into the `⋯` menu (the badge counts
321
- them). `pillPriority` decides what stays: `access` 30, `observe` (errors) 20, `ops` (CI) 10,
322
- everything else 0, then pill order. When no corner is free even after shifting, the pill
323
- turns compact and keeps only prioritised items.
378
+ them). `pillPriority` decides what stays, then pill order. When no corner is free even after
379
+ shifting, the pill turns compact and keeps only prioritised items.
324
380
  - Drag the env badge to another corner to keep the pill there; it still shifts within that
325
381
  corner to clear host elements. `⋯ → Reset layout` forgets the corner.
326
382
  - On a phone, a page wider than the screen grows the layout viewport past what is visible; the
@@ -328,7 +384,7 @@ through MSW with the same `createHudHandler` an app mounts.
328
384
 
329
385
  ## Panels and shortcuts
330
386
 
331
- - Open panels from the pill (`⋯` lists every panel and command). Drag by the title bar; a click
387
+ - Open panels from the dock (`⋯` lists every panel and command). Drag by the title bar; a click
332
388
  raises a panel.
333
389
  - Pin a panel with ◧ ⬓ ◨ or by dropping it at the left, right or bottom edge. Pinning pushes the
334
390
  page (padding on `<html>`) instead of covering it; pins on one edge stack. The host's
@@ -447,8 +503,25 @@ locale); an optional catch-all without a fixture resolves to its parent. A segme
447
503
  fixture leaves its route listed but unresolved. Capability: `routes.read` (development, staging,
448
504
  preview).
449
505
 
450
- The panel groups routes by route group, filters by path, marks the current page and navigates on
451
- click. `GET /api/hud/routes/routes` answers the same list as JSON.
506
+ The panel is a quick switcher. `⌘⇧R` (Ctrl+Shift+R elsewhere; the "Go to route" command, also in
507
+ the `⋯` menu) opens it with the filter focused and its text selected; ↓ ↑ move the highlight,
508
+ Enter navigates, Esc closes. Navigation goes through Next's router when the page has one
509
+ (`window.next.router`), else `location.assign`. The filter matches path, pattern and route group
510
+ and is fuzzy on segments: `dsys` finds `/de/dev/design-system`, `mark about` needs both words.
511
+ Routes are listed by route group; the current page is marked. Two sections come first while the
512
+ filter is empty: **Pinned** (the `pinned` globs plus the rows starred in the panel; the star on
513
+ every row toggles it, kept per app in `localStorage`) and **Recent** (the last eight routes
514
+ visited, most recent first, recorded by a navigation observer the plugin starts at HUD mount).
515
+ With a `[locale]` segment each route shows once, for the locale the page is on, the other locales
516
+ as chips behind the row. `GET /api/hud/routes/routes` answers the same list as JSON.
517
+
518
+ ```tsx
519
+ routes({
520
+ shortcut: "mod+shift+r", // the "Go to route" command; `mod` is ⌘ on Apple, Ctrl elsewhere
521
+ pinned: ["/*/dev/*"], // path globs listed first: `*` within a segment, `**` across segments
522
+ navigate: (url) => router.push(url), // replaces the default navigation
523
+ });
524
+ ```
452
525
 
453
526
  `hud sweep` visits that list headless and fails the build on a 5xx answer, an uncaught error or a
454
527
  console error on any page. It needs Playwright in the app (`playwright` or `@playwright/test`,
@@ -487,7 +560,7 @@ forceState();
487
560
  group's `scope` attribute), so themed and scoped tokens show what the page renders. It re-reads
488
561
  when `<html>`/`<body>` attributes, stylesheets or the OS color scheme change.
489
562
  - **Variants** lists the page's live variant groups (below) with a switcher, agent scores and
490
- Decide. An optional adapter (`variants({ categories, generate })`) adds the app's own variant
563
+ picks; `variants({ pages })` adds the [variant bar](#variant-bar). An optional adapter (`variants({ categories, generate })`) adds the app's own variant
491
564
  registry and the generate-brief queue (`variants.generate`).
492
565
  - **States** toggles every mounted `StateBoundary` between real, loading, empty and error. It
493
566
  needs `state.force`.
@@ -546,10 +619,10 @@ keyed `<group>:<id>`, which an agent writes by hand:
546
619
  }
547
620
  ```
548
621
 
549
- **Decide** (needs `variants.decide`, granted on development only by default) writes
550
- `status: "decided"` and `decidedAt` on the winner and `status: "rejected"` on the rest, then queues
551
- a cleanup brief ("inline the winner, delete the losers and the wrapper, run the checks") through
552
- the dispatch seam. The server half:
622
+ **Pick** (needs `variants.decide`, granted on development only by default) records the decision:
623
+ `status: "decided"` and `decidedAt` on the winner, `status: "rejected"` on the rest. A second click
624
+ takes it back. A pick only records; it queues nothing and starts no agent, whatever `dispatch` says.
625
+ The server half:
553
626
 
554
627
  ```ts
555
628
  import { variantsServer } from "@hansenexus/hud/plugins/design/server";
@@ -561,10 +634,84 @@ export const { GET, POST } = createHudHandler([
561
634
  ]);
562
635
  ```
563
636
 
564
- Without `dispatch` the decision is recorded and nothing is queued. `GET <apiBase>/variants/` lists
565
- the records, `POST <apiBase>/variants/<group>/decide` decides; both answer only to same-origin
566
- JSON requests. In the playground the hero is a variant group with seeded scores, and Decide logs
567
- the brief to the browser console through the echo provider.
637
+ `dispatch` is optional. With it the panel shows **Queue cleanup** next to a picked group: that
638
+ button, and only that button, sends the brief ("inline the winner, delete the losers and the
639
+ wrapper, run the checks") through the dispatch seam.
640
+
641
+ | route | does |
642
+ | --------------------------------------- | ---------------------------------------------------------------- |
643
+ | `GET <apiBase>/variants/` | lists the records, the notes and the logs |
644
+ | `POST <apiBase>/variants/<group>/pick` | `{ id, note }`: records the pick (`id: null` takes it back) and the note; a field left out stays as it is |
645
+ | `POST <apiBase>/variants/<group>/cleanup` | queues the brief for the picked variant; 409 without a pick or a provider |
646
+
647
+ Writes answer only to JSON requests from the app's own origin: by `Sec-Fetch-Site`, and where the
648
+ browser does not send it (plain http to another machine, such as a phone on the LAN address) the
649
+ `Origin` has to name the host the request went to. In the playground the hero is a variant group
650
+ with seeded scores, and Queue cleanup logs the brief to the browser console through the echo
651
+ provider.
652
+
653
+ ### Variant bar
654
+
655
+ A design round covers several pages. `pages` names them, and a bar at the bottom of the screen
656
+ steps through the pages and through the variants of the page it stands on, with a pick and a note
657
+ for each:
658
+
659
+ ```tsx
660
+ variants({
661
+ pages: [
662
+ { group: "hero", label: "Home", href: "/" },
663
+ { group: "plans", label: "Pricing", href: "/pricing" },
664
+ { group: "cluster", label: "Cluster", href: "#/estate/cluster" }, // a hash router
665
+ ],
666
+ });
667
+ ```
668
+
669
+ - `group` is the `VariantGroup` id the page decides. Where the address fits no page (a detail
670
+ page), the first mounted group on the list is the one the bar shows. Without `pages` there is no
671
+ bar.
672
+ - **Pages** open through Next's router when the page has one, else with a full load; a `#…` href is
673
+ the browser's own fragment navigation. `navigate: (href) => router.push(href)` replaces this. The
674
+ `?variant=` choices travel along.
675
+ - **Keys**: ⌥← ⌥→ step through the variants, ⌥↑ ⌥↓ through the pages, except while typing.
676
+ - **Pick** and **Note** go through the pick route above. A note saves with Save, with ⌘Enter, and
677
+ when the page changes under it; Escape drops the draft. A save that fails puts the recorded state
678
+ back and says why in the bar.
679
+ - × folds the bar to a pill with the score; that is kept per app in `localStorage`.
680
+ - The bar keeps clear of the HUD, of pinned panels and of fixed elements at the bottom of the page
681
+ (a bottom navigation, a chat bubble), and stays usable while a modal sheet is open: it is not
682
+ caught by `pointer-events: none` on `<body>`, by `inert` or by a focus trap, and pressing it does
683
+ not dismiss the sheet. The limit is a native `<dialog>` opened with `showModal()`, which the
684
+ browser puts above everything; there the keys still step, and picking waits until it is closed.
685
+ - **Development only.** The bar is its own chunk behind `process.env.NODE_ENV === "development"`;
686
+ `"data-hud-variant-bar"` is the string to grep production chunks for.
687
+
688
+ `.hud/variants.json` then holds, next to the variants, one entry per group with its note and a log
689
+ that only grows:
690
+
691
+ ```json
692
+ {
693
+ "hero": {
694
+ "label": "Hero",
695
+ "note": "Shorter claim, please",
696
+ "log": [
697
+ { "at": "2026-11-22T12:52:53.587Z", "pick": "bold", "note": "" },
698
+ { "at": "2026-11-22T12:53:10.101Z", "pick": "bold", "note": "Shorter claim, please" }
699
+ ]
700
+ },
701
+ "hero:bold": { "group": "hero", "id": "bold", "status": "decided", "decidedAt": "2026-11-22T12:52:53.587Z" }
702
+ }
703
+ ```
704
+
705
+ `hud variants` prints the decisions, for an agent or an issue:
706
+
707
+ ```sh
708
+ npx hud variants # Markdown, from .hud/ in the current directory
709
+ npx hud variants --json # the same as JSON
710
+ npx hud variants --dir apps/web/.hud # another directory
711
+ ```
712
+
713
+ `formatVariantsMarkdown(await readVariants(store))` from `@hansenexus/hud/plugins/design/server`
714
+ does the same for any other store.
568
715
 
569
716
  ## Storage seam
570
717
 
@@ -1,5 +1,6 @@
1
+ import { i as hudIcon } from "./icons-ByDyNq_E.js";
1
2
  import { n as HUD_HOST_TAG } from "./marker-uZYPOJ4M.js";
2
- import { i as definePlugin } from "./plugins-DVy_vaYr.js";
3
+ import { a as ratingTone, i as definePlugin } from "./plugins-CcW_K7c2.js";
3
4
  import { lazy, useSyncExternalStore } from "react";
4
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
6
  //#region src/plugins/a11y/axe.ts
@@ -205,7 +206,7 @@ function pillRating(snapshot) {
205
206
  }
206
207
  //#endregion
207
208
  //#region src/plugins/a11y/index.tsx
208
- const A11yPanel = lazy(() => import("./a11y-panel-p_t4eD7p.js"));
209
+ const A11yPanel = lazy(() => import("./a11y-panel-DcfXnPHk.js"));
209
210
  /**
210
211
  * On-demand axe-core audit. Nothing is fetched until Run: axe-core comes from
211
212
  * `axeUrl` (jsDelivr, pinned) or your own `load` (`() => import("axe-core")`).
@@ -227,9 +228,20 @@ function a11y(options = {}) {
227
228
  options
228
229
  });
229
230
  }
231
+ function useA11yBadge() {
232
+ const snapshot = useA11y();
233
+ const tone = ratingTone(pillRating(snapshot));
234
+ if (!tone) return null;
235
+ return snapshot.findings.length > 0 ? {
236
+ tone,
237
+ count: snapshot.findings.length
238
+ } : { tone };
239
+ }
230
240
  return definePlugin({
231
241
  id: "a11y",
232
242
  title: "A11y",
243
+ icon: hudIcon("accessibility"),
244
+ badge: useA11yBadge,
233
245
  pill: A11yPill,
234
246
  panel: Panel,
235
247
  commands: [{
@@ -1,5 +1,5 @@
1
1
  import { n as useGrab } from "./store-Ync9eb1G.js";
2
- import { c as targetLabel, n as runAudit, o as IMPACT_ORDER, r as useA11y, s as resolveTarget } from "./a11y-B5DUaiCs.js";
2
+ import { c as targetLabel, n as runAudit, o as IMPACT_ORDER, r as useA11y, s as resolveTarget } from "./a11y-BGWw4jBr.js";
3
3
  import { useEffect, useRef, useState } from "react";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/plugins/a11y/styles.ts
@@ -1,4 +1,4 @@
1
- import { r as HudCapability } from "./plugins-BZvDqGx5.js";
1
+ import { a as HudCapability } from "./plugins-pL2CoWzI.js";
2
2
  import { t as HudEnv } from "./env-CApnbI0r.js";
3
3
  //#region src/plugins/access/capabilities.d.ts
4
4
  /** The capability vocabulary of the default matrix. Development grants these and any other. */
@@ -1,5 +1,5 @@
1
1
  import { i as hudUnlockTtlMs, o as resolveHudAccess } from "./access-C7zlaqj6.js";
2
- import { n as useUnlockState, t as submitPassword } from "./unlock-store-4V3vR4Eg.js";
2
+ import { n as useUnlockState, t as submitPassword } from "./unlock-store-CrGXQx1V.js";
3
3
  import { useState } from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/plugins/access/access-panel.tsx
@@ -1,17 +1,17 @@
1
1
  import { t as HudAutoDetected } from "../detect-BxHZ0pxW.js";
2
- import { o as HudPlugin } from "../plugins-BZvDqGx5.js";
3
- import { n as a11y, t as A11yOptions } from "../index-DqOyNf1u.js";
4
- import { n as data } from "../index-DstI_ike.js";
5
- import { t as forceState } from "../index-Hhh7OXzU.js";
2
+ import { c as HudPlugin } from "../plugins-pL2CoWzI.js";
3
+ import { n as a11y, t as A11yOptions } from "../index-D97Fnoie.js";
4
+ import { n as data } from "../index-BqKysxTq.js";
5
+ import { n as forceState } from "../index-BeqWehuh.js";
6
6
  import { t as InspectAdapter } from "../adapter-BYoxPYTI.js";
7
- import { n as InspectOptions, r as inspect } from "../index-CwfX-W87.js";
7
+ import { n as InspectOptions, r as inspect } from "../index-DS0yT0c-.js";
8
8
  import { r as inspectConvex, t as ConvexClientLike } from "../index-BJ26pse9.js";
9
9
  import { i as inspectReactQuery, n as QueryClientLike } from "../index-RgXfMBuW.js";
10
10
  import { o as inspectSwr, t as InspectSwrOptions } from "../index-Dxz4fn4j.js";
11
- import { n as observe, t as ObserveOptions } from "../index-BAV_1W8a.js";
12
- import { t as routes } from "../index-BnQ0dTZf.js";
13
- import { t as seo } from "../index-DcH9V3cU.js";
14
- import { t as vitals } from "../index-ReFbhQ9p.js";
11
+ import { n as observe, t as ObserveOptions } from "../index-DvlCkGB1.js";
12
+ import { n as routes } from "../index-B7qaEUgh.js";
13
+ import { t as seo } from "../index-BGFyuJyN.js";
14
+ import { t as vitals } from "../index-B2KCKkN0.js";
15
15
  //#region src/auto/runtime.d.ts
16
16
  /**
17
17
  * What `auto()` takes: the instances a detected adapter wraps (a package can
package/dist/auto.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as HudAutoDetected } from "./detect-BxHZ0pxW.js";
2
- import { o as HudPlugin } from "./plugins-BZvDqGx5.js";
3
- import "./index-gCZBO53s.js";
2
+ import { c as HudPlugin } from "./plugins-pL2CoWzI.js";
3
+ import "./index-5B7foZut.js";
4
4
  import { HudAutoFactories, HudAutoOptions } from "./auto/runtime.js";
5
5
  //#region src/auto/index.d.ts
6
6
  /** Nothing detected: this is the stand-in (`configured: false`). */
package/dist/auto.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { t as NOTHING_DETECTED } from "./detect-CHZiSeZs.js";
2
- import { t as a11y } from "./a11y-B5DUaiCs.js";
3
- import { t as forceState } from "./design-D0kGgPoP.js";
4
- import { n as inspect } from "./inspect-C9Ft8fqn.js";
5
- import { t as observe } from "./observe-CdDnDBRP.js";
6
- import { t as seo } from "./seo-Dq9q_QkO.js";
2
+ import { t as a11y } from "./a11y-BGWw4jBr.js";
3
+ import { t as forceState } from "./design-BIXY1-Ex.js";
4
+ import { n as inspect } from "./inspect-CSkm8tn3.js";
5
+ import { t as observe } from "./observe-CBNLU148.js";
6
+ import { t as seo } from "./seo-BnnGq_vj.js";
7
7
  import { vitals } from "./plugins/vitals.js";
8
8
  import { assembleAuto } from "./auto/runtime.js";
9
9
  //#region src/auto/index.ts
package/dist/cli.js CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import { t as file } from "./file-xdSaQ2uR.js";
3
+ import { n as readVariants, t as formatVariantsMarkdown } from "./variants-export-vEtZ-OGC.js";
2
4
  import { r as isExcluded } from "./scan-DzJNXqOk.js";
3
5
  //#region src/plugins/routes/sweep.ts
4
6
  /** Console errors every dev server produces that never mean a broken page. */
@@ -164,7 +166,12 @@ const USAGE = `hud sweep --base <url> [options]
164
166
  Visits every route the running app's routes plugin lists, headless, and fails on
165
167
  a 5xx answer, an uncaught error or a console error.
166
168
 
167
- Options
169
+ hud variants [--json] [--dir <path>]
170
+
171
+ Prints the picks, notes and log of the variant bar from .hud/variants.json, as
172
+ Markdown for an issue or an agent.
173
+
174
+ Options of hud sweep
168
175
  --base <url> dev server origin, e.g. http://localhost:3000 (required)
169
176
  --api <path> where createHudHandler is mounted (default /api/hud)
170
177
  --json print the report as JSON instead of lines
@@ -173,6 +180,10 @@ Options
173
180
  --ignore-console <re> ignore console errors matching this pattern (repeatable)
174
181
  --exclude <path> skip a URL path or folder pattern, trailing * allowed (repeatable)
175
182
 
183
+ Options of hud variants
184
+ --json print JSON instead of Markdown
185
+ --dir <path> directory of the file store (default .hud)
186
+
176
187
  Exit codes: 0 clean, 1 at least one route failed, 2 usage or setup error.`;
177
188
  var UsageError = class extends Error {};
178
189
  function next(argv, i, flag) {
@@ -185,10 +196,27 @@ function integer(value, flag) {
185
196
  if (!Number.isInteger(n) || n < 0) throw new UsageError(`${flag} needs a non-negative integer`);
186
197
  return n;
187
198
  }
199
+ function parseVariants(rest) {
200
+ const args = {
201
+ command: "variants",
202
+ json: false
203
+ };
204
+ for (let i = 0; i < rest.length; i++) {
205
+ const flag = rest[i] ?? "";
206
+ if (flag === "--json") args.json = true;
207
+ else if (flag.startsWith("--dir=") && flag.length > 6) args.dir = flag.slice(6);
208
+ else if (flag === "--dir") {
209
+ args.dir = next(rest, i, flag);
210
+ i++;
211
+ } else throw new UsageError(`unknown option "${flag}"`);
212
+ }
213
+ return args;
214
+ }
188
215
  /** `argv` without the runtime and script. */
189
216
  function parseArgs(argv) {
190
217
  const [command, ...rest] = argv;
191
218
  if (command === void 0 || command === "--help" || command === "-h" || command === "help") return { command: "help" };
219
+ if (command === "variants") return parseVariants(rest);
192
220
  if (command !== "sweep") throw new UsageError(`unknown command "${command}"`);
193
221
  const args = {
194
222
  command: "sweep",
@@ -246,6 +274,11 @@ async function main(argv) {
246
274
  process.stdout.write(`${USAGE}\n`);
247
275
  return 0;
248
276
  }
277
+ if (args.command === "variants") {
278
+ const decisions = await readVariants(file(args.dir === void 0 ? {} : { dir: args.dir }));
279
+ process.stdout.write(`${args.json ? JSON.stringify(decisions, null, 2) : formatVariantsMarkdown(decisions)}\n`);
280
+ return 0;
281
+ }
249
282
  const quiet = args.json;
250
283
  const log = (line) => {
251
284
  if (!quiet) process.stdout.write(`${line}\n`);
@@ -1,5 +1,5 @@
1
1
  import { HUD_FLAG_SCOPES } from "./flags.js";
2
- import { a as useDataState, i as syncLocalOverrides, n as applyOverrides, r as errorMessage, s as useMockClientStatus, t as applyMocks } from "./data-store-ChF1td_P.js";
2
+ import { a as useDataState, i as syncLocalOverrides, n as applyOverrides, r as errorMessage, s as useMockClientStatus, t as applyMocks } from "./data-store-FNTQKMkG.js";
3
3
  import { useState } from "react";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/plugins/data/styles.ts
@@ -1,4 +1,4 @@
1
- import { n as HudApiError } from "./plugins-DVy_vaYr.js";
1
+ import { n as HudApiError } from "./plugins-CcW_K7c2.js";
2
2
  import { FLAGS_STORAGE_KEY, serializeFlagOverrides } from "./flags.js";
3
3
  import { d as validateScenarios, i as createMockResolver } from "./mocks-ESiRqk9o.js";
4
4
  import { useEffect, useSyncExternalStore } from "react";
@@ -1,5 +1,11 @@
1
- import { o as HudPlugin, r as HudCapability } from "./plugins-BZvDqGx5.js";
2
- import { ComponentType } from "react";
1
+ import { a as HudCapability, c as HudPlugin } from "./plugins-pL2CoWzI.js";
2
+ import { ComponentType, ReactNode } from "react";
3
+ //#region src/shell/panels/types.d.ts
4
+ /** The viewport edge the rail docks to. */
5
+ type DockSide = "left" | "right";
6
+ /** How the HUD docks: the vertical edge rail (default) or the horizontal corner pill. */
7
+ type HudDock = "rail" | "pill";
8
+ //#endregion
3
9
  //#region src/core/define-hud.d.ts
4
10
  /** `auto` from `@hansenexus/hud/auto`: the list, or the function itself. */
5
11
  type HudAutoPlugins = readonly HudPlugin[] | (() => readonly HudPlugin[]);
@@ -24,16 +30,20 @@ interface DefineHudOptions {
24
30
  apiBase?: string;
25
31
  /** Capability check. Default: grant all (core assumes development). */
26
32
  can?: (capability: HudCapability) => boolean;
33
+ /** The edge rail (default) or the horizontal corner pill. */
34
+ dock?: HudDock;
27
35
  }
28
36
  /** Props the loader passes in at mount time. */
29
37
  interface HudMountProps {
30
- /** Badge at the start of the pill. Default "DEV". */
38
+ /** Label of the env chip. Default "DEV". */
31
39
  envLabel?: string;
32
40
  /**
33
41
  * Tier the loader resolved. Default "development". Any other tier renders
34
42
  * nothing unless a plugin brings `access`.
35
43
  */
36
44
  env?: string;
45
+ /** Overrides `defineHud({ dock })` for this mount. */
46
+ dock?: HudDock;
37
47
  }
38
48
  /**
39
49
  * The app's one HUD file:
@@ -45,6 +55,6 @@ interface HudMountProps {
45
55
  * Returns a component. The plugin list is frozen here, so the shell sees a
46
56
  * stable array across renders.
47
57
  */
48
- declare function defineHud({ app, plugins, auto, apiBase, can }: DefineHudOptions): ComponentType<HudMountProps>;
58
+ declare function defineHud({ app, plugins, auto, apiBase, can, dock }: DefineHudOptions): ComponentType<HudMountProps>;
49
59
  //#endregion
50
- export { defineHud as i, HudAutoPlugins as n, HudMountProps as r, DefineHudOptions as t };
60
+ export { DockSide as a, defineHud as i, HudAutoPlugins as n, HudDock as o, HudMountProps as r, DefineHudOptions as t };
@@ -1,4 +1,5 @@
1
- import { i as definePlugin } from "./plugins-DVy_vaYr.js";
1
+ import { i as hudIcon } from "./icons-ByDyNq_E.js";
2
+ import { i as definePlugin } from "./plugins-CcW_K7c2.js";
2
3
  import { a as getForceStateSnapshot, c as subscribeForceState, o as getForceStateStore, s as resolveForcedState } from "./force-state-BaqWsmrf.js";
3
4
  import { lazy, useSyncExternalStore } from "react";
4
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -8,13 +9,16 @@ function useForceState() {
8
9
  }
9
10
  //#endregion
10
11
  //#region src/plugins/design/force-state-pill.tsx
12
+ function useForcedCount() {
13
+ const snapshot = useForceState();
14
+ return snapshot.boundaries.filter((b) => resolveForcedState(snapshot, b)).length;
15
+ }
11
16
  /**
12
17
  * Pill content: how many boundaries are forced, by toggle or param. Uses the
13
18
  * core `.dot`, since the plugin stylesheet only loads with the panel.
14
19
  */
15
20
  function ForceStatePill() {
16
- const snapshot = useForceState();
17
- const forced = snapshot.boundaries.filter((b) => resolveForcedState(snapshot, b)).length;
21
+ const forced = useForcedCount();
18
22
  if (forced === 0) return /* @__PURE__ */ jsx(Fragment, { children: "States" });
19
23
  return /* @__PURE__ */ jsxs(Fragment, { children: [
20
24
  /* @__PURE__ */ jsx("span", {
@@ -25,11 +29,20 @@ function ForceStatePill() {
25
29
  forced
26
30
  ] });
27
31
  }
32
+ /** The rail badge: the forced count, nothing while no boundary is forced. */
33
+ function useForceStateBadge() {
34
+ const forced = useForcedCount();
35
+ return forced > 0 ? {
36
+ tone: "warn",
37
+ count: forced
38
+ } : null;
39
+ }
28
40
  //#endregion
29
41
  //#region src/plugins/design/index.tsx
30
42
  const TokensPanel = lazy(() => import("./tokens-panel-CbMQfasZ.js"));
31
- const VariantsPanel = lazy(() => import("./variants-panel-BDoSkwBJ.js"));
32
- const ForceStatePanel = lazy(() => import("./force-state-panel-_otVYh9i.js"));
43
+ const VariantsPanel = lazy(() => import("./variants-panel-D23v5KIp.js"));
44
+ const ForceStatePanel = lazy(() => import("./force-state-panel-D5oDydLs.js"));
45
+ const VariantBar = process.env.NODE_ENV === "development" ? lazy(() => import("./variant-bar-BzZ0ln-C.js")) : void 0;
33
46
  /**
34
47
  * Live swatches of the host app's design tokens. Values are read from the
35
48
  * host document, outside the HUD's shadow root, so scoped and themed tokens
@@ -42,27 +55,46 @@ function tokens(adapter) {
42
55
  return definePlugin({
43
56
  id: "tokens",
44
57
  title: "Tokens",
58
+ icon: hudIcon("palette"),
45
59
  panel: Panel
46
60
  });
47
61
  }
48
62
  /**
49
63
  * The page's live variant groups (`VariantGroup` from `@hansenexus/hud/variants`)
50
- * with a switcher, agent scores from the storage seam and Decide, which
51
- * needs `variants.decide` and `variantsServer()` from
52
- * `@hansenexus/hud/plugins/design/server`. An adapter adds the app's own
53
- * variant registry and the generate-brief queue (`variants.generate`). Client only.
64
+ * with a switcher and agent scores from the storage seam. `pages` adds the
65
+ * variant bar, which steps through them and records picks and notes. Picks
66
+ * need `variants.decide` and `variantsServer()` from
67
+ * `@hansenexus/hud/plugins/design/server`. The adapter fields add the app's
68
+ * own variant registry and the generate-brief queue (`variants.generate`).
69
+ * Client only.
54
70
  */
55
- function variants(adapter) {
71
+ function variants(options = {}) {
72
+ const { pages, navigate, ...adapter } = options;
56
73
  function Panel({ ctx }) {
57
74
  return /* @__PURE__ */ jsx(VariantsPanel, {
58
75
  adapter,
59
76
  ctx
60
77
  });
61
78
  }
62
- return definePlugin({
79
+ const plugin = {
63
80
  id: "variants",
64
81
  title: "Variants",
82
+ icon: hudIcon("layers"),
65
83
  panel: Panel
84
+ };
85
+ if (!VariantBar || !pages || pages.length === 0) return definePlugin(plugin);
86
+ const Bar = VariantBar;
87
+ const barPages = pages;
88
+ function Overlay({ ctx }) {
89
+ return /* @__PURE__ */ jsx(Bar, {
90
+ pages: barPages,
91
+ navigate,
92
+ ctx
93
+ });
94
+ }
95
+ return definePlugin({
96
+ ...plugin,
97
+ overlay: Overlay
66
98
  });
67
99
  }
68
100
  /**
@@ -74,6 +106,8 @@ function forceState() {
74
106
  id: "states",
75
107
  title: "States",
76
108
  capability: "state.force",
109
+ icon: hudIcon("toggle"),
110
+ badge: useForceStateBadge,
77
111
  pill: ForceStatePill,
78
112
  panel: ForceStatePanel,
79
113
  commands: [{
@@ -1,5 +1,5 @@
1
1
  import { n as useGrab } from "./store-Ync9eb1G.js";
2
- import { n as HudApiError } from "./plugins-DVy_vaYr.js";
2
+ import { n as HudApiError } from "./plugins-CcW_K7c2.js";
3
3
  import { i as parseShortcut, n as isApplePlatform, s as matchComponentHints, t as formatShortcut } from "./shortcut-s_mjGeU8.js";
4
4
  import { t as AGENT_CSS } from "./styles-DPpDPmzi.js";
5
5
  import { useEffect, useState, useSyncExternalStore } from "react";
@@ -1,5 +1,5 @@
1
1
  import { i as formatForceStateParam, o as getForceStateStore, r as FORCE_STATE_PARAM, s as resolveForcedState, t as FORCED_STATES } from "./force-state-BaqWsmrf.js";
2
- import { i as useForceState } from "./design-D0kGgPoP.js";
2
+ import { i as useForceState } from "./design-BIXY1-Ex.js";
3
3
  import { t as DESIGN_CSS } from "./styles-DKU_P8MH.js";
4
4
  import { useEffect } from "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1,4 +1,4 @@
1
- import { a as resolvePlugins, t as HUD_HTTP_METHODS } from "./plugins-DVy_vaYr.js";
1
+ import { o as resolvePlugins, t as HUD_HTTP_METHODS } from "./plugins-CcW_K7c2.js";
2
2
  //#region src/server/handler.ts
3
3
  function json(status, body, headers) {
4
4
  const res = Response.json(body, { status });