synthesisui 0.16.37 → 0.16.39

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.
@@ -99,17 +99,27 @@ async function detectStack(root) {
99
99
  stack.push("plain css");
100
100
  return stack;
101
101
  }
102
- /** Their own vocabulary, read from stylesheets - the same harvest the doctor
103
- * runs when nothing of ours is installed. */
104
- async function declaredTokens(root) {
102
+ /**
103
+ * Their own vocabulary, read from stylesheets - the same harvest the doctor runs
104
+ * when nothing of ours is installed.
105
+ *
106
+ * Returns the TABLE, not just the names, because the scan needs it. The first
107
+ * version harvested the names for the payload and then scanned with an EMPTY
108
+ * table, which made the census blind in a way a real app exposed (dono, 30/07):
109
+ * a project with 2416 uses of its own `var(--dashboard-*)` reported
110
+ * `tokenUses: 0`, `coverage: 0`, and `token: null` on every single value. The
111
+ * sharpest sentence the doctor knows - "your own system already has a name for
112
+ * this" - could not be said, and we ended up rediscovering by colour distance
113
+ * what their stylesheet had spelled out all along.
114
+ */
115
+ async function harvestOwnTable(root) {
105
116
  let css = "";
106
117
  for await (const file of walkAll([root])) {
107
118
  if (!/\.(css|scss|sass|less)$/i.test(file))
108
119
  continue;
109
120
  css += `\n${await readFile(file, "utf8").catch(() => "")}`;
110
121
  }
111
- const table = buildTable({ css, source: "yours" });
112
- return Object.fromEntries(table.byName);
122
+ return buildTable({ css, source: "yours" });
113
123
  }
114
124
  /**
115
125
  * EVERY distinct design value, commonest first - not just the repeated ones.
@@ -202,7 +212,7 @@ function distinctValues(d) {
202
212
  return kept.sort((a, b) => b.count - a.count || a.value.localeCompare(b.value));
203
213
  }
204
214
  export async function takeCensus(root) {
205
- const table = buildTable({ css: "", source: "yours" });
215
+ const table = await harvestOwnTable(root);
206
216
  const reports = [];
207
217
  for await (const file of walk(root)) {
208
218
  const src = await readFile(file, "utf8").catch(() => "");
@@ -224,7 +234,7 @@ export async function takeCensus(root) {
224
234
  return {
225
235
  census: 1,
226
236
  project: { name, stack: await detectStack(root) },
227
- declared: await declaredTokens(root),
237
+ declared: Object.fromEntries(table.byName),
228
238
  observed: distinctValues(d),
229
239
  totals: {
230
240
  scanned: d.scanned,
@@ -251,6 +261,12 @@ function summarize(c) {
251
261
  if (Object.keys(c.declared).length > 0) {
252
262
  console.log(body(`${Object.keys(c.declared).length} tokens you already declare - your names travel unchanged`));
253
263
  }
264
+ // The sharpest number in the report, and it only became sayable once the scan
265
+ // started using their own token table: not "you have drift" but "you have
266
+ // drift your own system already solved".
267
+ if (c.totals.named > 0) {
268
+ console.log(body(`${paint.strong(String(c.totals.named))} of those values ALREADY have a name in your system - ${c.totals.coverage}% of your design values come from it today`));
269
+ }
254
270
  const top = c.observed.slice(0, 5);
255
271
  if (top.length > 0) {
256
272
  console.log("");
@@ -375,7 +391,7 @@ export async function runImport(opts) {
375
391
  if (n?.decisions && n.decisions > 0) {
376
392
  console.log("");
377
393
  console.log(section("What a v2 would normalize"));
378
- console.log(body(`${paint.strong(String(n.decisions))} colour${n.decisions === 1 ? "" : "s"} in your code ${n.decisions === 1 ? "is" : "are"} the same decision typed twice - ${paint.strong(String(n.retires ?? 0))} uses would retire.`));
394
+ console.log(body(`${paint.strong(String(n.decisions))} colour decision${n.decisions === 1 ? "" : "s"} to settle - ${paint.strong(String(n.governs ?? n.retires ?? 0))} uses would come under a name.`));
379
395
  for (const line of n.lines ?? [])
380
396
  console.log(body(paint.dim(line)));
381
397
  console.log("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synthesisui",
3
- "version": "0.16.37",
3
+ "version": "0.16.39",
4
4
  "description": "Bring SynthesisUI design systems into any project - tokens, typed components, whole pages and an agent-ready CLAUDE.md manifest.",
5
5
  "type": "module",
6
6
  "bin": {