synthesisui 0.16.371 → 0.16.373

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.
@@ -94,7 +94,7 @@ export async function localMisalignments(root,
94
94
  * máquina que roda o teste não é verificável: ela passa ou falha conforme quem está logado ali.
95
95
  */
96
96
  opts = {}) {
97
- const { cli, home = homedir() } = opts;
97
+ const { cli, home = homedir(), justMeasured = 0 } = opts;
98
98
  const out = [];
99
99
  const locks = (await locksIn(root)).filter((l) => l.slug && !l.adopted);
100
100
  /** Sem sistema instalado não há alinho a cobrar - não é desalinho, é um repo sem DS. */
@@ -214,11 +214,27 @@ opts = {}) {
214
214
  * número só crescia.
215
215
  */
216
216
  const events = await unsentEvents(root).catch(() => []);
217
- if (events.length > 0)
217
+ if (events.length > 0) {
218
+ /**
219
+ * O QUE ESTA RODADA MEDIU NÃO É EVIDÊNCIA VELHA - ver `justMeasured`.
220
+ *
221
+ * "the platform is scoring this repo on older evidence" é verdade quando o registro esperava
222
+ * desde ontem, e é enganoso quando a leitura tem três segundos e foi este comando que a fez. As
223
+ * duas frases pedem o MESMO `sync`, de propósito: o registro só sai da máquina quando a pessoa
224
+ * manda, e nada aqui desconta um evento que realmente não subiu. O que muda é o que a linha
225
+ * ensina - consequência do que ela acabou de fazer, em vez de dívida que ela deixou acumular.
226
+ *
227
+ * SÓ QUANDO TODOS OS PENDENTES VIERAM DAQUI. Com cinco esperando de antes e um novo, há
228
+ * evidência velha de verdade, e a frase de sempre é a honesta.
229
+ */
230
+ const allFromThisRun = justMeasured > 0 && justMeasured >= events.length;
218
231
  out.push({
219
- says: `${events.length} checked write${events.length === 1 ? "" : "s"} recorded here and not sent - the platform is scoring this repo on older evidence.`,
232
+ says: allFromThisRun
233
+ ? "This run measured the app, and that reading is still on this machine - the platform keeps scoring the previous one until you send it."
234
+ : `${events.length} checked write${events.length === 1 ? "" : "s"} recorded here and not sent - the platform is scoring this repo on older evidence.`,
220
235
  run: "npx synthesisui sync",
221
236
  });
237
+ }
222
238
  /**
223
239
  * O DÉCIMO ESTADO: os ARQUIVOS deste install foram escritos por um CLI anterior.
224
240
  *
@@ -597,6 +613,8 @@ opts = {}) {
597
613
  const items = await localMisalignments(root, {
598
614
  ...(opts.cli ? { cli: opts.cli } : {}),
599
615
  ...(opts.home ? { home: opts.home } : {}),
616
+ /** ATRAVESSA - ver `home` acima: uma porta que não repassa é a regressão da 0.16.365 de novo. */
617
+ ...(opts.justMeasured ? { justMeasured: opts.justMeasured } : {}),
600
618
  }).catch(() => []);
601
619
  /** A única linha que custa rede, e ela some inteira quando não há rede. */
602
620
  const remote = await versionBehind(root, {
@@ -877,6 +877,21 @@ export async function doctor(opts) {
877
877
  * `"yours"` e `"adopted"` são o vocabulário dela, e não há duas linhas para ligar.
878
878
  */
879
879
  const blocked = table.source === "installed" && (!wiring.imported || !wiring.scoped);
880
+ /**
881
+ * QUANTAS DAS DUAS FALTAM - e sem este número três frases mandavam consertar DUAS coisas quando
882
+ * faltava UMA.
883
+ *
884
+ * `blocked` é um OU, e as frases que ele governa foram escritas assumindo o E: *"Until both are
885
+ * true"*, *"--fix is refused while those two are false"* e *"Wire the two lines first"*. Visto na
886
+ * máquina do dono em 04/09, num repositório onde `data-ds` já estava lá com um ✓ impresso três
887
+ * linhas acima: a tela contradizia a própria lista, e a terceira frase é INSTRUÇÃO - a pessoa está
888
+ * bloqueada, procurando o que escrever, e ela manda escrever duas linhas.
889
+ *
890
+ * O caso de faltar UMA é o mais comum: uma instalação que parou no meio erra um dos dois passos,
891
+ * não os dois. Derivado da mesma leitura que decide `blocked`, para as duas nunca discordarem.
892
+ */
893
+ const missingWiring = (wiring.imported ? 0 : 1) + (wiring.scoped ? 0 : 1);
894
+ const bothMissing = missingWiring === 2;
880
895
  const unwired = table.source === "installed" &&
881
896
  (!wiring.imported || !wiring.scoped || fontsPending);
882
897
  if (unwired) {
@@ -907,7 +922,9 @@ export async function doctor(opts) {
907
922
  * enquanto imprimia o número abaixo; agora não há número abaixo, e prometer um seria a mesma
908
923
  * incoerência ao contrário.
909
924
  */
910
- console.log(body(`Until both are true, none of the ${table.byName.size} tokens reach the browser.`));
925
+ console.log(body(bothMissing
926
+ ? `Until both are true, none of the ${table.byName.size} tokens reach the browser.`
927
+ : `Until that one is true, none of the ${table.byName.size} tokens reach the browser.`));
911
928
  }
912
929
  else {
913
930
  console.log(body("Colour and spacing are working. Type is not: the system's faces"));
@@ -965,10 +982,12 @@ export async function doctor(opts) {
965
982
  }).catch(() => { });
966
983
  console.log("");
967
984
  if (opts.fix) {
968
- console.log(body(`--fix is refused while those two are false. ${d.named} of your hand-written values`));
969
- console.log(body("do have a name in the system, and swapping them now would point them at"));
970
- console.log(body("variables the browser cannot resolve - the declarations would be dropped"));
971
- console.log(body("and the page would change. Wire the two lines first."));
985
+ /** `1 ... do have` saía assim desde sempre; a frase que recusa um comando não pode tropeçar. */
986
+ const one = d.named === 1;
987
+ console.log(body(`--fix is refused while ${bothMissing ? "those two are" : "that one is"} false. ${d.named} of your hand-written values`));
988
+ console.log(body(`${one ? "does" : "do"} have a name in the system, and swapping ${one ? "it" : "them"} now would point ${one ? "it" : "them"} at`));
989
+ console.log(body(`variables the browser cannot resolve - the ${one ? "declaration" : "declarations"} would be dropped`));
990
+ console.log(body(`and the page would change. Wire ${bothMissing ? "the two lines" : "that line"} first.`));
972
991
  }
973
992
  else {
974
993
  console.log(body(`${d.named} of the ${d.findings.length} hand-written values found have a name waiting in`));
@@ -4,6 +4,7 @@ import { pinnedHookVersion, wireAgent } from "../agent-wiring.js";
4
4
  import { isOlderCli } from "../cli-version.js";
5
5
  import { generateComponentFiles } from "../component-codegen.js";
6
6
  import { readProjectConfig, readToken, resolveRegistry } from "../config.js";
7
+ import { unsentEvents } from "../doctor/ledger.js";
7
8
  import { diffLocalDocuments, localChangelogMarkdown, } from "../document-diff.js";
8
9
  import { installedBehind, MATERIALISER_SINCE } from "../install-marks.js";
9
10
  import { body, section, snippet } from "../output.js";
@@ -174,12 +175,30 @@ async function rewireIfBehind(root, cli) {
174
175
  * NUNCA `strict`. Um achado é informação, não falha do upgrade, e sair com erro por causa do drift da
175
176
  * própria pessoa transformaria uma instalação bem-sucedida num terminal vermelho.
176
177
  */
178
+ /**
179
+ * DEVOLVE QUANTAS MEDIÇÕES ESTA CHAMADA DEIXOU PARA TRÁS, e é isso que impede o comando de cobrar
180
+ * de si mesmo.
181
+ *
182
+ * O `upgrade` termina imprimindo o que ainda falta, e o que faltava incluía o registro que ELE
183
+ * acabou de gravar aqui: quem rodava `sync` e em seguida `upgrade` via a tela pedir `sync` de novo e
184
+ * concluía que o primeiro não tinha adiantado. A lista continua pedindo o envio - o registro só sai
185
+ * da máquina quando a pessoa manda, e isso não se contorna -, mas passa a dizer que a leitura é
186
+ * desta rodada em vez de chamá-la de evidência velha. Ver `justMeasured` em `align.ts`.
187
+ *
188
+ * LIDO DO DISCO, antes e depois. O doctor grava em três pontos diferentes e nenhum deles reporta
189
+ * quantos; contar os não enviados nos dois instantes responde a pergunta sem que nenhuma das três
190
+ * chamadas precise concordar com esta. É o mesmo instrumento que o spec da re-materialização usa,
191
+ * e pela mesma razão: o ledger não tem como concordar por engano.
192
+ */
177
193
  async function checkAfterWriting(root, version) {
194
+ const before = await unsentEvents(root).catch(() => []);
178
195
  console.log(section(`Checking the app against ${version}`));
179
196
  await doctor({ dir: root }).catch((err) => {
180
197
  /** Um doctor que não roda não é um upgrade que falhou: os artefatos já estão em disco e certos. */
181
198
  console.log(body(`The check could not run (${err instanceof Error ? err.message : "unknown"}). Run \`npx synthesisui doctor\` when you can.`));
182
199
  });
200
+ const after = await unsentEvents(root).catch(() => []);
201
+ return Math.max(0, after.length - before.length);
183
202
  }
184
203
  async function theOnlyInstalled(root) {
185
204
  const dsDir = join(root, "_synthesisui", "ds");
@@ -242,8 +261,11 @@ export async function upgrade(asked, opts) {
242
261
  * `sync` seguinte respondeu `6 checks sent, 0 new` - o comando disse que atualizou e nada foi
243
262
  * medido.
244
263
  */
245
- await checkAfterWriting(root, `v${installed}`);
246
- await reportWhatIsLeft(root, opts.cli ? { cli: opts.cli } : {});
264
+ const measured = await checkAfterWriting(root, `v${installed}`);
265
+ await reportWhatIsLeft(root, {
266
+ ...(opts.cli ? { cli: opts.cli } : {}),
267
+ ...(measured > 0 ? { justMeasured: measured } : {}),
268
+ });
247
269
  return;
248
270
  }
249
271
  if (!opts.force) {
@@ -430,7 +452,7 @@ export async function upgrade(asked, opts) {
430
452
  for (const k of kept)
431
453
  console.log(body(keptLine(slug, k.entry, k.edited)));
432
454
  }
433
- await checkAfterWriting(root, `v${latest.version}`);
455
+ const measured = await checkAfterWriting(root, `v${latest.version}`);
434
456
  console.log(section("Migrate the app"));
435
457
  console.log(body(`The migration brief is at _synthesisui/ds/${slug}/UPGRADE.md`));
436
458
  console.log("");
@@ -441,6 +463,9 @@ export async function upgrade(asked, opts) {
441
463
  ]));
442
464
  console.log("");
443
465
  console.log(body(`(rollback: synthesisui add ${slug} --version ${installed})`));
444
- await reportWhatIsLeft(root, opts.cli ? { cli: opts.cli } : {});
466
+ await reportWhatIsLeft(root, {
467
+ ...(opts.cli ? { cli: opts.cli } : {}),
468
+ ...(measured > 0 ? { justMeasured: measured } : {}),
469
+ });
445
470
  console.log("");
446
471
  }
@@ -235,13 +235,43 @@ values) {
235
235
  * VALOR daquilo está no sistema, e não só que não há o que consertar.
236
236
  */
237
237
  const theirs = group.reduce((n, g) => n + (g.withTheirTokens ?? 0), 0);
238
- lines.push("", `${label[verdict]} - ${total} fragment${total === 1 ? "" : "s"}, ${unread > 0 ? Math.round((total / unread) * 100) : 0}% of what was not interpreted${theirs > 0
238
+ lines.push("",
239
+ /**
240
+ * O DENOMINADOR VAI NA FRASE - e a falta dele era o mesmo defeito consertado pela METADE.
241
+ *
242
+ * A linha de cima estabelece decisões (1063, das quais 1007 interpretadas: 56 fora), e este
243
+ * percentual é sobre FRAGMENTOS (32). Dizer só "of what was not interpreted" faz as duas
244
+ * grandezas usarem a mesma palavra na mesma tela: quem soma 81 + 9 + 9 conclui que a triagem
245
+ * cobriu tudo, e ela cobriu 32 de 56.
246
+ *
247
+ * Em 03/09 o dono viu exatamente isto e o conserto reescreveu a linha do MEIO ("They live in N
248
+ * places in your code"). Estes três cabeçalhos ficaram com a expressão antiga - mesma tela,
249
+ * mesmo defeito, na parte que não foi olhada. Visto de novo em 04/09.
250
+ */
251
+ `${label[verdict]} - ${total} fragment${total === 1 ? "" : "s"}, ${unread > 0 ? Math.round((total / unread) * 100) : 0}% of those ${unread} place${unread === 1 ? "" : "s"}${theirs > 0
239
252
  ? ` — and ${theirs} of them already wear a token you declare, so their value is in the system`
240
253
  : ""}`);
241
254
  for (const gap of group) {
242
255
  lines.push(` ${gap.uses} ${gap.shape} in ${gap.files} file${gap.files === 1 ? "" : "s"} (${gap.share}%) - ${gap.work}`);
243
- for (const example of gap.examples.slice(0, 2))
256
+ /**
257
+ * TODOS OS QUE O CENSO GUARDOU, E O QUE FICOU DE FORA DITO EM VOZ ALTA.
258
+ *
259
+ * Isto cortava em dois (`slice(0, 2)`) sobre os até TRÊS que `style-ledger` grava - um por
260
+ * arquivo -, e não dizia nada. Na tela do dono em 04/09: *"3 class in 3 files"* seguido de dois
261
+ * arquivos, e o terceiro sumiu sem uma palavra. Ele conserta dois e acha que acabou.
262
+ *
263
+ * O GÊMEO JÁ TINHA O AVISO e este não: a tela de admin ganhou *"Not the whole set: N more"* no
264
+ * #1304. Duas superfícies respondem a mesma pergunta, e só uma admitia o corte - que é a Lei 8
265
+ * ao contrário, lacuna calada.
266
+ *
267
+ * O QUE FALTA SÃO ARQUIVOS, e é isso que a linha conta: o censo guarda um exemplo por arquivo,
268
+ * então `files` menos os mostrados é literalmente quantos arquivos você não está vendo.
269
+ */
270
+ for (const example of gap.examples)
244
271
  lines.push(` ${example.file}:${example.line} ${example.text.slice(0, 76)}`);
272
+ const hidden = gap.files - gap.examples.length;
273
+ if (hidden > 0)
274
+ lines.push(` not the whole set: ${hidden} more file${hidden === 1 ? "" : "s"} with this shape, not listed here`);
245
275
  }
246
276
  }
247
277
  return lines;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synthesisui",
3
- "version": "0.16.371",
3
+ "version": "0.16.373",
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": {