@inversestudio/storybook-addon 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,5 +2,13 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.2.0 — 2026-12-01
6
+
7
+ - **History and Activity tabs in the Studio panel.** History lists the component's newest changes: what the commit said, when, who, whether an agent made it, and what kind of change it was (props, variants, tokens), with breaking changes marked. Activity shows its commits in the last year and the latest date, how many of the recent changes agents made and how many people made, and who changed it. Both come from storybook.json, from what `studio health` bakes (studio-kit 0.146.10 or later); before that, the tabs say how to get it. **Test:** packages/studio-kit/test/storybook-addon.smoke.js.
8
+
9
+ - **README: how to turn the History and Activity tabs off.** It now names the kit's `storybook.history: false` setting, which leaves history out of storybook.json; the tabs then say there's no history. Docs only; no add-on code changed. **Test:** packages/studio-kit/test/storybook-addon.smoke.js (the history:false check).
10
+
11
+ ## 0.1.0 — 2026-11-30
12
+
5
13
  - First version: a "Studio" tab beside every story with Readiness, Contrast, Spec and Used in, read from the `storybook.json` that `studio health` (`studio-showcase-data`) bakes. Storybook 9 and 10. Public; it imports no studio-kit code.
6
14
  - A **Theme** switch in the toolbar: the design system's themes from storybook.json, applied to the story the way the token sheet selects them (`[data-theme="dark"]`, `.dark`). Framework-agnostic: the decorator only sets an attribute or class on `<html>`.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @inversestudio/storybook-addon
2
2
 
3
- studio's data beside every story, in a **Studio** panel: whether the component is ready, its contrast in every theme, its design spec, and where it's used.
3
+ studio's data beside every story, in a **Studio** panel: whether the component is ready, its contrast in every theme, its design spec, where it's used, its history and who changed it.
4
4
 
5
5
  For Storybook 9 and 10.
6
6
 
@@ -19,6 +19,8 @@ export default {
19
19
 
20
20
  The panel reads `storybook.json`, which `studio health` writes next to the Showcase's data (`health.dataDir`, `showcase/data` by default). Run it, then start Storybook.
21
21
 
22
+ **History** and **Activity** come from what `studio health` bakes from git: the component's newest changes (what kind of change, breaking ones marked) and how many were made by agents and how many by people. An agent's commit is one with a coding agent as co-author (`Co-authored-by: Claude …`), a `[bot]` author, or a subject prefix from `health.activity.agentPrefixes`. They need studio-kit 0.146.10 or later. storybook.json ships with a published Storybook; for one the public can open, `"storybook": { "history": false }` in studio.config.json leaves the history out.
23
+
22
24
  A story names its component with `parameters: { studio: { component: "Button" } }`. The stories `studio generate` writes do. Without it, the last part of the story's title is used.
23
25
 
24
26
  The toolbar gets a **Theme** switch with the design system's themes, from the same file. It sets the theme the way your token sheet selects it (`[data-theme="dark"]` or `.dark` on `<html>`). "default" leaves the page as your CSS has it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inversestudio/storybook-addon",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "studio's data beside every story: readiness, contrast in every theme, the design spec and where a component is used.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/manager.js CHANGED
@@ -24,6 +24,8 @@ const TABS = [
24
24
  ["contrast", "Contrast"],
25
25
  ["spec", "Spec"],
26
26
  ["used", "Used in"],
27
+ ["history", "History"],
28
+ ["activity", "Activity"],
27
29
  ];
28
30
 
29
31
  const styles = {
@@ -79,6 +81,38 @@ function Used({ c }) {
79
81
  );
80
82
  }
81
83
 
84
+ const day = (iso) => { const d = new Date(iso); return Number.isNaN(+d) ? "" : d.toLocaleDateString(); };
85
+ const NO_HISTORY = "No history yet. `studio health` bakes it from git, then `studio-showcase-data` (or `npm run storybook`) brings it in.";
86
+ const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
87
+
88
+ function History({ c }) {
89
+ const hs = c.history;
90
+ if (!hs?.nodes?.length) return h("p", { style: styles.muted }, NO_HISTORY);
91
+ return h("div", null,
92
+ h("p", { style: styles.muted }, `${plural(hs.commits, "change")}${hs.truncated ? " (the most recent; older ones aren't baked)" : ""}`),
93
+ h("ul", { style: { ...styles.list, listStyle: "none", paddingLeft: 0 } }, hs.nodes.map((n) => h("li", { key: n.sha, style: { margin: "6px 0" } },
94
+ h("div", null, n.subject || "(no message)"),
95
+ h("div", { style: { ...styles.muted, fontSize: 12 } },
96
+ [day(n.when), n.author, n.agent ? "agent" : null, n.sha, n.lane].filter(Boolean).join(" · "),
97
+ n.changes?.total ? ` · ${plural(n.changes.total, "change")}${n.changes.kinds.length ? ` (${n.changes.kinds.join(", ")})` : ""}` : "",
98
+ n.changes?.breaking ? h("span", { style: styles.no }, ` · ${n.changes.breaking} breaking`) : null,
99
+ ),
100
+ ))),
101
+ );
102
+ }
103
+
104
+ function Activity({ c }) {
105
+ const a = c.activity;
106
+ if (!a) return h("p", { style: styles.muted }, NO_HISTORY);
107
+ const people = c.history?.contributors || [];
108
+ return h("div", null,
109
+ a.updates != null ? h("p", null, `${plural(a.updates, "commit")} in the last year${a.lastUpdated ? `, the latest on ${day(a.lastUpdated)}` : ""}.`) : null,
110
+ a.recent ? h("p", null, `Of the last ${plural(a.recent, "change")}: ${a.byAgents} by agents, ${a.byPeople} by people.`) : null,
111
+ people.length ? h("div", null, h("strong", null, "Who changed it"), h("ul", { style: styles.list }, people.map((p) => h("li", { key: p.author }, `${p.author} (${p.commits})`)))) : null,
112
+ h("p", { style: { ...styles.muted, fontSize: 11 } }, "An agent's change: a commit with a coding agent as co-author (Co-authored-by: Claude …), a bot's, or one whose subject starts with a prefix such as [agent] (health.activity.agentPrefixes)."),
113
+ );
114
+ }
115
+
82
116
  function Panel() {
83
117
  const [data, setData] = useState(null);
84
118
  const [tab, setTab] = useState("readiness");
@@ -91,7 +125,7 @@ function Panel() {
91
125
  if (data.missing) return h("div", { style: styles.wrap }, h("p", null, "No studio data yet. Run `studio health` in the project, then restart Storybook."));
92
126
  const c = data.components?.[name];
93
127
  if (!c) return h("div", { style: styles.wrap }, h("p", null, `studio has no component named "${name}".`), h("p", { style: styles.muted }, "Name it in the story: parameters: { studio: { component: 'Name' } }."));
94
- const Body = { readiness: Readiness, contrast: Contrast, spec: Spec, used: Used }[tab];
128
+ const Body = { readiness: Readiness, contrast: Contrast, spec: Spec, used: Used, history: History, activity: Activity }[tab];
95
129
  return h("div", { style: styles.wrap },
96
130
  h("div", { style: styles.tabs }, TABS.map(([id, label]) => h("button", { key: id, type: "button", style: styles.tab(tab === id), onClick: () => setTab(id), "aria-pressed": tab === id }, label))),
97
131
  h(Body, { c }),