@behavioral-agentic-design-system/core 0.39.0 → 0.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,94 @@
1
+ "use client";
2
+
3
+ import { useCallback, useEffect, useState } from "react";
4
+ import { brand } from "@/brand.config";
5
+ import {
6
+ SegmentedControl,
7
+ SegmentedControlItem,
8
+ } from "@behavioral-agentic-design-system/core/components/ui/segmented-control";
9
+
10
+ /**
11
+ * Active-discipline picker.
12
+ *
13
+ * Lives in Customize, not in the shell rail. Discipline is a setting, not a
14
+ * destination: it changes which rule tree an agent loads for the work, and it
15
+ * changes rarely. Putting it in the chrome implied it was a mode you flip
16
+ * between while browsing, which it is not.
17
+ *
18
+ * This is signal 1 ("explicit") of the router in
19
+ * `disciplines/_router/router.config.ts`. It writes two places:
20
+ *
21
+ * - `localStorage` under DISCIPLINE_KEY, so the choice survives a reload.
22
+ * - `<html data-discipline>`, so stylesheets and anything reading the DOM can
23
+ * branch on it without importing from React.
24
+ *
25
+ * The enabled list comes from `brand.config.disciplines`, which is also the
26
+ * router's signal-4 fallback — one declaration of what a fork supports. A fork
27
+ * that lists a single discipline renders nothing here at all.
28
+ */
29
+
30
+ /** Persisted in localStorage, not session: a discipline is a standing choice. */
31
+ export const DISCIPLINE_KEY = "bads:shell:discipline";
32
+
33
+ export function DisciplineSection() {
34
+ const config = (brand as {
35
+ disciplines?: { enabled?: readonly string[]; default?: string };
36
+ }).disciplines;
37
+ const enabled: readonly string[] = config?.enabled ?? [];
38
+ const [discipline, setDiscipline] = useState(config?.default ?? enabled[0] ?? "product");
39
+
40
+ useEffect(() => {
41
+ if (enabled.length < 2) return;
42
+ let stored: string | null = null;
43
+ try {
44
+ stored = window.localStorage.getItem(DISCIPLINE_KEY);
45
+ } catch {
46
+ // Storage disabled (Safari private, lockdown mode) — keep the default.
47
+ }
48
+ const next = stored && enabled.includes(stored) ? stored : discipline;
49
+ setDiscipline(next);
50
+ document.documentElement.dataset.discipline = next;
51
+ // `enabled` and `discipline` are read once, at mount, on purpose: this
52
+ // effect restores the persisted choice and must not re-run when the user
53
+ // changes it (selectDiscipline already owns that path).
54
+ // eslint-disable-next-line react-hooks/exhaustive-deps
55
+ }, []);
56
+
57
+ const selectDiscipline = useCallback((next: string) => {
58
+ setDiscipline(next);
59
+ document.documentElement.dataset.discipline = next;
60
+ try {
61
+ window.localStorage.setItem(DISCIPLINE_KEY, next);
62
+ } catch {
63
+ // Non-fatal: the choice still holds for this session.
64
+ }
65
+ }, []);
66
+
67
+ // One discipline means there is nothing to choose. Render nothing rather than
68
+ // a control with a single option.
69
+ if (enabled.length < 2) return null;
70
+
71
+ return (
72
+ <div>
73
+ <h2 className="mb-2 text-2xl font-semibold tracking-tight">Discipline</h2>
74
+ <p className="mb-5 max-w-prose text-sm text-muted-foreground">
75
+ Which rule tree agents load for this work. Product covers app surfaces
76
+ such as dashboards, forms and settings. Marketing covers expressive brand
77
+ surfaces such as landing pages, email and campaigns. The accessibility
78
+ and ethics floors load for both either way.
79
+ </p>
80
+ <SegmentedControl
81
+ value={discipline}
82
+ onValueChange={selectDiscipline}
83
+ label="Active discipline"
84
+ className="max-w-sm"
85
+ >
86
+ {enabled.map((d) => (
87
+ <SegmentedControlItem key={d} value={d} className="flex-1 capitalize">
88
+ {d}
89
+ </SegmentedControlItem>
90
+ ))}
91
+ </SegmentedControl>
92
+ </div>
93
+ );
94
+ }
@@ -36,6 +36,7 @@ import {
36
36
  import { TypeScalePanel } from "@behavioral-agentic-design-system/core/components/customize/type-scale";
37
37
  import { LetterSpacingPanel } from "@behavioral-agentic-design-system/core/components/customize/letter-spacing";
38
38
  import { SaveBar } from "@behavioral-agentic-design-system/core/components/customize/save-bar";
39
+ import { DisciplineSection } from "@behavioral-agentic-design-system/core/components/customize/discipline-section";
39
40
  import { nameFromHex } from "@behavioral-agentic-design-system/core/lib/color-name";
40
41
 
41
42
  type TokenSwatchPickerCtx = {
@@ -776,6 +777,7 @@ export function CustomizeTab() {
776
777
  return (
777
778
  <ScrollArea className="size-full">
778
779
  <div className="motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-2 motion-safe:duration-500">
780
+ <DisciplineSection />
779
781
  <ColorPalette />
780
782
  </div>
781
783
  </ScrollArea>
@@ -8,6 +8,7 @@ import {
8
8
  Area,
9
9
  Line,
10
10
  Dot,
11
+ YAxis,
11
12
  } from "recharts"
12
13
 
13
14
  import { cn } from "../../lib/utils"
@@ -116,7 +117,10 @@ function Sparkline({
116
117
  [data]
117
118
  )
118
119
 
119
- // Compute domain so flat/negative data still renders a visible shape.
120
+ // Compute domain so flat/negative data still renders a visible shape. This
121
+ // is fed to a hidden <YAxis> below — without it Recharts nice-ticks its own
122
+ // default axis (and anchors positive-only series at 0), which squeezes the
123
+ // series into a fraction of the box.
120
124
  const min = Math.min(...data)
121
125
  const max = Math.max(...data)
122
126
  const padding = max === min ? 1 : (max - min) * 0.1
@@ -174,11 +178,18 @@ function Sparkline({
174
178
  <stop offset="95%" stopColor={color} stopOpacity={0} />
175
179
  </linearGradient>
176
180
  </defs>
181
+ <YAxis domain={domain} hide yAxisId={0} />
177
182
  <Area
178
183
  {...commonLineProps}
179
184
  fill={`url(#${gradientId})`}
180
185
  fillOpacity={1}
181
186
  yAxisId={0}
187
+ // Anchor the fill to the bottom of the plot area. Recharts'
188
+ // default baseValue resolves to 0, which for a mixed-sign
189
+ // series draws a hard horizontal edge across the middle of the
190
+ // sparkline and leaves the negative lobes in the gradient's
191
+ // transparent tail.
192
+ baseValue={domain[0]}
182
193
  />
183
194
  </AreaChart>
184
195
  ) : (
@@ -186,6 +197,7 @@ function Sparkline({
186
197
  data={chartData}
187
198
  margin={{ top: 2, right: 2, bottom: 2, left: 2 }}
188
199
  >
200
+ <YAxis domain={domain} hide yAxisId={0} />
189
201
  <Line {...commonLineProps} yAxisId={0} />
190
202
  </LineChart>
191
203
  )}
@@ -90,7 +90,9 @@ export const DOCS_INDEX: DocGroup[] = [
90
90
  { title: "Night Shift spec", path: "CIRCADIAN.md", summary: "The overnight agent: what it audits, researches, builds, tests, merges, and reports each night." },
91
91
  { title: "Night Shift prompt", path: "scripts/prompts/night-shift.md", summary: "The full nightly research + auto-PR pass." },
92
92
  { title: "Agent roadmap", path: "docs/agent-roadmap.md" },
93
+ { title: "Disciplines — product vs marketing", path: "disciplines/README.md", summary: "The discipline axis: one fork serves both product and marketing work on a shared spine, and a four-signal router (explicit \u2192 route \u2192 classify \u2192 default) decides which rule tree loads. The three spine manifests load for every discipline because the accessibility and ethics floors are discipline-neutral. Promoted upstream 2026-09-09 from the ohmyaura fork when a second client needed it." },
93
94
  { title: "Intent-driven context", path: "docs/intent-driven-context.md", summary: "Constraint vs guideline vs framing vs workflow — and what delivery each demands." },
95
+ { title: "Social sources bench", path: "docs/social-sources.md", summary: "Sir-curated bench of practitioner accounts (X, LinkedIn, Reddit, Medium, Bluesky/Mastodon) the Night Shift's social signal sweep checks — so it reads known-good signal, not the firehose. Carries the lowest-trust-tier rules (a social post alone is never an actionable finding) and the ToS boundaries (search-driven, never logged-in scraping; LinkedIn read-through-search only)." },
94
96
  ],
95
97
  },
96
98
  {
@@ -222,6 +224,8 @@ export const DOCS_INDEX: DocGroup[] = [
222
224
  { title: "Spec — self-healing layer", path: "docs/specs/2026-08-21-self-healing-layer.md", summary: "Phase A contract: informational-only health score (Goodhart guard), no runtime telemetry, deterministic visible-copy intent rules, drift-ledger status convention, and the calibration record (6→0 false positives; two scoring bugs caught by face-checking)." },
223
225
  { title: "Plan — drift elimination", path: "docs/plans/2026-08-31-drift-elimination.md", summary: "Closing the loop between upstream, client forks, and prototype repos. Built on the one artifact every working template-sync tool shares: a committed record of which upstream version a downstream copy is layered on. Three phases ordered by risk — additive checks, then PR-gated fork sync, then the deferred structural calls." },
224
226
  { title: "Spec — drift elimination", path: "docs/specs/2026-08-31-drift-elimination.md", summary: "Phase A contract: precision over recall (unverifiable is never reported as drift), advisory-by-default with one blocking generated-artifact gate, additive-only sync manifest, and declared expected-drift allowlists. Calibration: 51→0 false positives on the registry checker, and real drift caught including llms.txt advertising 79 components when there were 173." },
227
+ { title: "Plan — Best-of-N", path: "docs/plans/2026-09-10-best-of-n.md", summary: "Run one judgment N times and treat disagreement as the signal. Two uses: a three-verifier unanimity panel before Code Review Carl can force-merge a fix, and an eval agreement score that finds the rules repeated runs resolve differently. Rejects a merge agent and majority vote for the gate, and says why." },
228
+ { title: "Spec — Best-of-N", path: "docs/specs/2026-09-10-best-of-n.md", summary: "The contract for scripts/verifier-panel.mjs (unanimous, fail-closed, distinct lenses, evidence-backed approvals) and scripts/eval-agreement.mjs (check stability, primitive choice, import path, drift rows only from the with-context arm). Records the first measurement: a skill rule sending agents to the package root, 3 of 15 before the fix and 0 of 15 after." },
225
229
  { title: "Roadmap — ClosedLoop import candidates", path: "docs/roadmap-closedloop-import.md", summary: "Fourteen production patterns surfaced by auditing the closedloop-ai GitHub org (40 repos, 17 cloned, 2026-09-03). Three shipped immediately; the rest carry activation signals matching the standard roadmap format." },
226
230
  ],
227
231
  },
@@ -0,0 +1,269 @@
1
+ {
2
+ "$comment": "GENERATED by scripts/build-history.mjs — do not edit. Regenerate with `pnpm build:history`.",
3
+ "generatedAt": "2026-09-09",
4
+ "stats": [
5
+ {
6
+ "label": "commits",
7
+ "value": 1214
8
+ },
9
+ {
10
+ "label": "components",
11
+ "value": 180
12
+ },
13
+ {
14
+ "label": "semantic tokens",
15
+ "value": 45
16
+ },
17
+ {
18
+ "label": "layers",
19
+ "value": 10
20
+ }
21
+ ],
22
+ "genesis": {
23
+ "sha": "548b1ffe",
24
+ "date": "2026-05-04",
25
+ "subject": "Initial commit: BADS template v0.1.0"
26
+ },
27
+ "milestones": [
28
+ {
29
+ "sha": "f916cd24",
30
+ "date": "2026-09-09",
31
+ "scope": "shell",
32
+ "title": "replace the top tabs with a left rail, and promote the discipline tree upstream"
33
+ },
34
+ {
35
+ "sha": "2b3fe69f",
36
+ "date": "2026-09-09",
37
+ "scope": "storybook",
38
+ "title": "keep the variant galleries out of the AI manifest (#460)"
39
+ },
40
+ {
41
+ "sha": "31fd2924",
42
+ "date": "2026-09-09",
43
+ "scope": "progress",
44
+ "title": "add xl size (16px) to track height ladder (#445)"
45
+ },
46
+ {
47
+ "sha": "98ca9802",
48
+ "date": "2026-09-09",
49
+ "scope": "alert",
50
+ "title": "add sm size variant for compact / dense-layout use (#446)"
51
+ },
52
+ {
53
+ "sha": "7cda871b",
54
+ "date": "2026-09-09",
55
+ "scope": "components",
56
+ "title": "FormatDate + WeekPicker + Sparkline [Night Shift]"
57
+ },
58
+ {
59
+ "sha": "0fedeb8c",
60
+ "date": "2026-09-06",
61
+ "scope": "accordion",
62
+ "title": "add contained and separated visual variants (#447)"
63
+ },
64
+ {
65
+ "sha": "a7e9e817",
66
+ "date": "2026-09-06",
67
+ "scope": "tags-input",
68
+ "title": "add size prop sm/default/lg/xl (#444)"
69
+ },
70
+ {
71
+ "sha": "cef5617b",
72
+ "date": "2026-09-06",
73
+ "scope": "checkbox-card",
74
+ "title": "add size prop sm/default/lg (#443)"
75
+ },
76
+ {
77
+ "sha": "3e333c2f",
78
+ "date": "2026-09-06",
79
+ "scope": "checkbox",
80
+ "title": "add lg size 40px (#442)"
81
+ },
82
+ {
83
+ "sha": "640e144f",
84
+ "date": "2026-09-06",
85
+ "scope": "breadcrumb",
86
+ "title": "add dropdown variant for long paths (#439)"
87
+ },
88
+ {
89
+ "sha": "03279eba",
90
+ "date": "2026-09-05",
91
+ "scope": "components",
92
+ "title": "Avatar xl/xs sizes, ToggleGroup vertical, Tag icon slot (night-shift 2026-09-03)"
93
+ },
94
+ {
95
+ "sha": "f9c74daa",
96
+ "date": "2026-09-03",
97
+ "scope": "night-shift",
98
+ "title": "give Carl a bundle-delta efficiency floor"
99
+ },
100
+ {
101
+ "sha": "b1e04bbc",
102
+ "date": "2026-09-03",
103
+ "scope": "night-shift",
104
+ "title": "add four governance crew members + weekly deep-dive"
105
+ },
106
+ {
107
+ "sha": "cfc3e8d9",
108
+ "date": "2026-09-03",
109
+ "scope": "night-shift",
110
+ "title": "add Code Review Carl — staff-engineer review pass (step 3f)"
111
+ },
112
+ {
113
+ "sha": "8aee3811",
114
+ "date": "2026-09-01",
115
+ "scope": "scripts",
116
+ "title": "port accent-as-text lint from CL-BADS, add stale-exception detection to wcag-audit"
117
+ },
118
+ {
119
+ "sha": "e2165388",
120
+ "date": "2026-09-01",
121
+ "scope": "eval",
122
+ "title": "score the rules BADS actually enforces, from one shared definition"
123
+ },
124
+ {
125
+ "sha": "02b90ce5",
126
+ "date": "2026-09-01",
127
+ "scope": "multi-select",
128
+ "title": "add size prop (sm/default/lg/xl) (#430)"
129
+ },
130
+ {
131
+ "sha": "6878a6a2",
132
+ "date": "2026-09-01",
133
+ "scope": "combobox",
134
+ "title": "add size prop (sm/default/lg/xl) threading to Button trigger (#429)"
135
+ },
136
+ {
137
+ "sha": "020526e3",
138
+ "date": "2026-08-31",
139
+ "scope": "cards",
140
+ "title": "add ChatThread composition (#421)"
141
+ },
142
+ {
143
+ "sha": "8a53f8db",
144
+ "date": "2026-08-31",
145
+ "scope": "radio-group",
146
+ "title": "wire orientation prop to visual layout (#420)"
147
+ },
148
+ {
149
+ "sha": "266f9d18",
150
+ "date": "2026-08-31",
151
+ "scope": "switch",
152
+ "title": "add lg size variant (44×80px, SC 2.5.5 Enhanced compliant) (#419)"
153
+ },
154
+ {
155
+ "sha": "ff566d2a",
156
+ "date": "2026-08-31",
157
+ "scope": "home",
158
+ "title": "upstream shows a fork prompt; forks show their own prompts"
159
+ },
160
+ {
161
+ "sha": "cfa883eb",
162
+ "date": "2026-08-31",
163
+ "scope": "drift",
164
+ "title": "Phase B — ship the checks to consumers, make fleet drift visible"
165
+ },
166
+ {
167
+ "sha": "6ecf12ac",
168
+ "date": "2026-08-31",
169
+ "scope": "drift",
170
+ "title": "drift elimination Phase A — generated-artifact gate, registry truth, doctor, sync manifest v2, CLAUDE.md freshness"
171
+ },
172
+ {
173
+ "sha": "0f7128a2",
174
+ "date": "2026-08-30",
175
+ "scope": "pagination",
176
+ "title": "size prop — sm / default / lg (Tier 4, Night Shift 2026-08-30) (#414)"
177
+ },
178
+ {
179
+ "sha": "dabbf55e",
180
+ "date": "2026-08-30",
181
+ "scope": "progress",
182
+ "title": "striped and animated variants (Tier 4, Night Shift 2026-08-30)"
183
+ },
184
+ {
185
+ "sha": "9112a926",
186
+ "date": "2026-08-30",
187
+ "scope": "Textarea",
188
+ "title": "add size prop — sm / default / lg / xl via CVA (#404)"
189
+ },
190
+ {
191
+ "sha": "938f194a",
192
+ "date": "2026-08-29",
193
+ "scope": "Input",
194
+ "title": "add ghost and filled variant props (#411)"
195
+ },
196
+ {
197
+ "sha": "4f0e1b1e",
198
+ "date": "2026-08-29",
199
+ "scope": null,
200
+ "title": "add Table striped/bordered/compact variants (#409) [Night Shift]"
201
+ },
202
+ {
203
+ "sha": "20f54a22",
204
+ "date": "2026-08-29",
205
+ "scope": "DataTable",
206
+ "title": "add stickyHeader prop + Table wrapperClassName/wrapperStyle (#405)"
207
+ },
208
+ {
209
+ "sha": "11e74884",
210
+ "date": "2026-08-28",
211
+ "scope": "RadioGroupItem",
212
+ "title": "add size prop — sm / default / lg via CVA (#406)"
213
+ },
214
+ {
215
+ "sha": "d277fc62",
216
+ "date": "2026-08-27",
217
+ "scope": "select",
218
+ "title": "add lg and xl size variants (#396)"
219
+ },
220
+ {
221
+ "sha": "ad927e12",
222
+ "date": "2026-08-27",
223
+ "scope": "search-input",
224
+ "title": "add SearchInput composition primitive (#397)"
225
+ },
226
+ {
227
+ "sha": "506ab78a",
228
+ "date": "2026-08-26",
229
+ "scope": "ethics",
230
+ "title": "apply 8 HIGH data-entry findings — registry anti-patterns + lint"
231
+ },
232
+ {
233
+ "sha": "b8a14b22",
234
+ "date": "2026-08-26",
235
+ "scope": "lint",
236
+ "title": "guard against analytics SDKs in @core; close stale PostHog findings"
237
+ },
238
+ {
239
+ "sha": "056731e7",
240
+ "date": "2026-08-26",
241
+ "scope": "skeleton-table",
242
+ "title": "add SkeletonTable sub-component [Night Shift] (#355)"
243
+ },
244
+ {
245
+ "sha": "d9e2c5f2",
246
+ "date": "2026-08-26",
247
+ "scope": "[Night Shift]",
248
+ "title": "feat([Night Shift]) Add Progress intent prop (#367)"
249
+ },
250
+ {
251
+ "sha": "86a364ac",
252
+ "date": "2026-08-26",
253
+ "scope": "[Night Shift]",
254
+ "title": "feat([Night Shift]) Add Checkbox size prop (#368)"
255
+ },
256
+ {
257
+ "sha": "a6aac73f",
258
+ "date": "2026-08-26",
259
+ "scope": "rename",
260
+ "title": "make a fresh fork's docs speak as the fork (#381)"
261
+ },
262
+ {
263
+ "sha": "0fd4f0d9",
264
+ "date": "2026-08-26",
265
+ "scope": null,
266
+ "title": "add ToggleTip component (#378) [Night Shift]"
267
+ }
268
+ ]
269
+ }
@@ -14,6 +14,15 @@ import { Input } from "@behavioral-agentic-design-system/core/components/ui/inpu
14
14
  import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
15
15
  import { Textarea } from "@behavioral-agentic-design-system/core/components/ui/textarea";
16
16
  import { Avatar, AvatarFallback } from "@behavioral-agentic-design-system/core/components/ui/avatar";
17
+ // A static import, not a require() inside render.
18
+ //
19
+ // This was `const { PortalThemeProvider } = require(...)` with an eslint-disable
20
+ // on it, which works under Node and is simply undefined in a browser bundle:
21
+ // the story threw `require is not defined` on every run. It went unnoticed
22
+ // because the Storybook a11y suite has been failing to start at all, so no
23
+ // story has actually executed in CI for some time — see vitest.config.ts.
24
+ import { PortalThemeProvider } from "@behavioral-agentic-design-system/core/hooks/use-portal-theme-class";
25
+
17
26
 
18
27
  const meta: Meta<typeof Sheet> = {
19
28
  title: "Components/Overlays/Sheet",
@@ -166,9 +175,6 @@ export const Side_Bottom_NoHandle: Story = {
166
175
  // repository-level theme classes.
167
176
  export const WithPortalTheme: Story = {
168
177
  render: () => {
169
- const { PortalThemeProvider } =
170
- // eslint-disable-next-line @typescript-eslint/no-require-imports
171
- require("@behavioral-agentic-design-system/core/hooks/use-portal-theme-class");
172
178
  return (
173
179
  <PortalThemeProvider scope="dark">
174
180
  <Sheet>
@@ -34,6 +34,10 @@ const USER_DATA = [82, 95, 104, 98, 117, 131, 128, 142]
34
34
  const CHURN_DATA = [8.2, 7.9, 8.5, 7.4, 7.1, 6.8, 6.3, 6.0]
35
35
  // Negative / mixed dataset
36
36
  const NEGATIVE_DATA = [-12, 4, -8, 15, -3, 22, 8, -5]
37
+ // Flat dataset — a metric that hasn't moved. Exercises the `max === min`
38
+ // branch of the domain padding, which is the only path where the series has
39
+ // no range of its own to scale against.
40
+ const FLAT_DATA = [64, 64, 64, 64, 64, 64, 64, 64]
37
41
 
38
42
  export const Default: Story = {
39
43
  render: () => (
@@ -110,6 +114,38 @@ export const Negative: Story = {
110
114
  ),
111
115
  }
112
116
 
117
+ export const FlatData: Story = {
118
+ // Two sparklines side by side is the point of this story: it proves the flat
119
+ // path centres the series in both area and line mode. That can't be driven
120
+ // from a single set of args, so the Controls panel is disabled rather than
121
+ // left present and inert (check:story-controls).
122
+ parameters: { controls: { disable: true } },
123
+ render: () => (
124
+ <div className="flex flex-col gap-4">
125
+ <div className="flex flex-col gap-1">
126
+ <Sparkline
127
+ data={FLAT_DATA}
128
+ type="area"
129
+ className="w-32"
130
+ aria-label="Flat trend, no change over the period"
131
+ />
132
+ <p className="text-xs text-muted-foreground">Area — no change</p>
133
+ </div>
134
+ <div className="flex flex-col gap-1">
135
+ <Sparkline
136
+ data={FLAT_DATA}
137
+ type="line"
138
+ className="w-32"
139
+ aria-label="Flat trend line, no change over the period"
140
+ />
141
+ <p className="text-xs text-muted-foreground">
142
+ Line — the series sits mid-box rather than pinned to an edge
143
+ </p>
144
+ </div>
145
+ </div>
146
+ ),
147
+ }
148
+
113
149
  export const RealisticUse: Story = {
114
150
  render: () => {
115
151
  const stats = [