@domandigital/craft 0.15.0 → 0.17.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.
@@ -4,14 +4,16 @@ import {
4
4
  REFLEX_FONTS_1,
5
5
  REFLEX_FONTS_2,
6
6
  SHARED_PART,
7
- TRADE_NOUNS,
8
7
  deltaEOk,
9
8
  isAiViolet,
10
9
  isCream,
11
10
  levenshtein,
12
11
  normaliseFamily,
13
12
  parseColour
14
- } from "./chunk-LFNSB6W7.js";
13
+ } from "./chunk-WFB6F3BN.js";
14
+ import {
15
+ TRADE_NOUNS
16
+ } from "./chunk-4QWEAL4G.js";
15
17
 
16
18
  // src/direction/types.ts
17
19
  var DIRECTION_VERSION = 2;
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  snapshotUrl,
3
3
  snapshotUrls
4
- } from "./chunk-OUQ25LY2.js";
4
+ } from "./chunk-SL5VZJ2J.js";
5
5
  import {
6
6
  describeTypicality,
7
7
  loadNull
8
- } from "./chunk-RXXRXV3V.js";
8
+ } from "./chunk-ZUYERAFM.js";
9
9
  import {
10
10
  SOURCE_FILE,
11
11
  finish,
@@ -13,9 +13,11 @@ import {
13
13
  loadExceptions,
14
14
  parseFlags,
15
15
  prepareReport,
16
- readPaths,
16
+ readPaths
17
+ } from "./chunk-O5B5ELJH.js";
18
+ import {
17
19
  toJson
18
- } from "./chunk-MUVFECFC.js";
20
+ } from "./chunk-QIEDBL4J.js";
19
21
  import {
20
22
  readSnapshot
21
23
  } from "./chunk-WUACK2HX.js";
@@ -25,7 +27,7 @@ import {
25
27
  fingerprint,
26
28
  scanSource,
27
29
  typicality
28
- } from "./chunk-LFNSB6W7.js";
30
+ } from "./chunk-WFB6F3BN.js";
29
31
 
30
32
  // src/audit/cli.ts
31
33
  import { existsSync, readFileSync, writeFileSync } from "fs";
@@ -1,49 +1,3 @@
1
- import {
2
- merge
3
- } from "./chunk-2IQ5OXFR.js";
4
- import "./chunk-OUQ25LY2.js";
5
- import "./chunk-JYNXGCYZ.js";
6
- import {
7
- SIBLING_AT,
8
- compareToEstate,
9
- loadEstate
10
- } from "./chunk-QU6Q2QZZ.js";
11
- import {
12
- PAGE_TYPES,
13
- validateDirection
14
- } from "./chunk-YDURAOYR.js";
15
- import {
16
- loadNull
17
- } from "./chunk-RXXRXV3V.js";
18
- import "./chunk-OQXTQQAU.js";
19
- import {
20
- COPY_FILE,
21
- NOT_COPY_DIR,
22
- SOURCE_FILE,
23
- applySeverity,
24
- loadConfig,
25
- loadExceptions,
26
- parseFlags,
27
- readPaths,
28
- toJson
29
- } from "./chunk-MUVFECFC.js";
30
- import {
31
- readSnapshot
32
- } from "./chunk-WUACK2HX.js";
33
- import {
34
- CATALOGUE,
35
- auditSnapshot,
36
- checkCopy,
37
- fingerprint,
38
- scanSource,
39
- typicality
40
- } from "./chunk-LFNSB6W7.js";
41
- import "./chunk-QYBAVU3P.js";
42
-
43
- // src/report/cli.ts
44
- import { existsSync, readFileSync, writeFileSync } from "fs";
45
- import { dirname, resolve } from "path";
46
-
47
1
  // src/report/index.ts
48
2
  var TELL_HEAVY = 3;
49
3
  var MIN_DECIDED = 5;
@@ -199,144 +153,7 @@ function choiceOfShared(part) {
199
153
  return /running order/.test(part) ? void 0 : "motif";
200
154
  }
201
155
 
202
- // src/report/retrofit.ts
203
- var HEADINGS = {
204
- direction: "Decide first",
205
- type: "Type",
206
- colour: "Colour",
207
- shape: "Shape",
208
- effects: "Effects",
209
- motion: "Motion",
210
- layout: "How sections look (not where they sit)",
211
- copy: "Copy"
212
- };
213
- var ORDER = ["direction", "type", "colour", "shape", "effects", "motion", "layout", "copy"];
214
- function target(a, direction) {
215
- if (!a.choice || a.area === "direction") return "";
216
- const c = direction?.choices?.[a.choice];
217
- if (c && c.because && !c.because.startsWith("PROPOSED:")) return `
218
- - Use: **${c.value}** for ${a.choice}. ${c.because}`;
219
- return `
220
- - Waits on: deciding **${a.choice}** in art-direction.json.`;
221
- }
222
- function retrofitPlan(report, direction) {
223
- const lines = [
224
- `# Retrofit: ${report.site}`,
225
- "",
226
- `**Now:** ${report.verdict}. ${report.summary}`,
227
- "",
228
- "| Signal | Raised | Reading |",
229
- "|---|---|---|",
230
- ...report.signals.map((s) => `| ${s.id} | ${s.raised === null ? "not measured" : s.raised ? "yes" : "no"} | ${s.detail} |`),
231
- "",
232
- "**Done when** `craft report` says *decided*: fewer than three design tells, typicality under 0.10 against this brief's null, no sibling in the estate, and at least five of the seven choices decided with a reason.",
233
- ""
234
- ];
235
- let n = 0;
236
- for (const area of ORDER) {
237
- const list = report.actions.filter((a) => a.area === area);
238
- if (list.length === 0) continue;
239
- n += 1;
240
- lines.push(`## ${n}. ${HEADINGS[area]}`, "");
241
- for (const a of list) lines.push(`- [ ] ${a.what} *(${a.why})*${target(a, direction)}`);
242
- lines.push("");
243
- }
244
- if (n === 0) lines.push("Nothing to change.", "");
245
- lines.push(
246
- "## Leave alone",
247
- "",
248
- "Navigation, the order of the sections, where the call to action sits, reading order and legibility. Change the look, never the page grammar. A layout tell above is about how a section looks: the icon tiles, the chip, the strip. The section stays where it is.",
249
- ""
250
- );
251
- return lines.join("\n");
252
- }
253
-
254
- // src/report/cli.ts
255
- var USAGE = "usage: craft report|retrofit <url | snapshot.json> [--repo <dir>] [--null <dir>] [--estate <estate.json>] [--direction <file>] [--json] [--out <file>]";
256
- var sameUrl = (a, b) => a.replace(/\/+$/, "").toLowerCase() === b.replace(/\/+$/, "").toLowerCase();
257
- function formatCharacter(r) {
258
- const lines = [`craft report ${r.site}`, "", `Verdict: ${r.verdict.toUpperCase()}. ${r.summary}`, ""];
259
- for (const s of r.signals) lines.push(` ${s.id.padEnd(11)} ${s.raised === null ? "\xB7" : s.raised ? "RAISED" : "ok"} ${s.detail}`);
260
- lines.push("", "What to do, in order:");
261
- r.actions.slice(0, 12).forEach((a, i) => lines.push(` ${String(i + 1).padStart(2)}. [${a.area}] ${a.what}`, ` ${a.why}`));
262
- if (r.actions.length > 12) lines.push(` ...and ${r.actions.length - 12} more: craft retrofit writes them all.`);
263
- return lines.join("\n");
264
- }
265
- async function runReport(command, args, io) {
266
- try {
267
- const flags = parseFlags(args);
268
- if (typeof flags === "string") throw new Error(flags);
269
- const target2 = flags.positional[0];
270
- if (!target2) throw new Error(USAGE);
271
- const page = flags.page ?? "home";
272
- if (!PAGE_TYPES.includes(page)) throw new Error(`--page takes one of ${PAGE_TYPES.join(", ")}`);
273
- const local = resolve(io.cwd, target2);
274
- let snap;
275
- if (/\.json$/i.test(target2) && existsSync(local)) {
276
- snap = readSnapshot(JSON.parse(readFileSync(local, "utf8")), target2);
277
- } else {
278
- const { snapshotUrl } = await import("./audit-MTUC24XU.js");
279
- snap = await snapshotUrl(target2);
280
- }
281
- const fp = fingerprint(snap);
282
- const repo = flags.repo ? resolve(io.cwd, flags.repo) : null;
283
- const exceptions = loadExceptions(flags, repo ?? io.cwd);
284
- const config = loadConfig(flags, repo ?? io.cwd);
285
- let findings = auditSnapshot(snap, { exceptions });
286
- if (repo) {
287
- findings = merge(scanSource(readPaths(["."], repo, SOURCE_FILE, void 0, config.ignore), { exceptions }), findings);
288
- const copyPaths = config.copyPaths ?? ["."];
289
- findings = merge(findings, checkCopy(readPaths(copyPaths, repo, COPY_FILE, (d) => NOT_COPY_DIR(d) || d === "docs", config.ignore), { exceptions }));
290
- }
291
- findings = applySeverity(findings, config);
292
- const nulls = flags.null ? flags.null.split(",").map((p) => loadNull(p.trim(), io.cwd)) : [];
293
- const typical = nulls.length ? typicality(fp, nulls.flatMap((m, i) => m.runs.map((r) => nulls.length > 1 ? { ...r, id: `${i + 1}/${r.id}` } : r))) : null;
294
- let estate = null;
295
- if (flags.estate) {
296
- const register = loadEstate(resolve(io.cwd, flags.estate));
297
- const self = register.sites.find((s) => sameUrl(s.url, snap.url));
298
- estate = compareToEstate(fp, register, { exclude: self?.id, siblingAt: SIBLING_AT });
299
- }
300
- const directionFile = resolve(repo ?? io.cwd, flags.direction ?? "art-direction.json");
301
- let direction = null;
302
- let directionReport = null;
303
- if (existsSync(directionFile)) {
304
- direction = JSON.parse(readFileSync(directionFile, "utf8"));
305
- directionReport = validateDirection(direction, {
306
- fingerprint: fp,
307
- snapshot: snap,
308
- page,
309
- strict: flags.strict,
310
- pathExists: (p) => existsSync(resolve(dirname(directionFile), p)),
311
- readSource: (s) => {
312
- if (!s.path || /^https?:/.test(s.path) || !/\.(?:txt|md|markdown|csv|json|html?)$/i.test(s.path)) return void 0;
313
- const path = resolve(dirname(directionFile), s.path);
314
- return existsSync(path) ? readFileSync(path, "utf8") : void 0;
315
- }
316
- });
317
- } else if (flags.direction) {
318
- throw new Error(`no such file: ${flags.direction}`);
319
- }
320
- const copyTells = new Set(CATALOGUE.filter((t) => t.surface === "copy").map((t) => t.id));
321
- const report = characterReport({ site: snap.url, findings, typicality: typical, estate, direction: directionReport }, copyTells);
322
- if (command === "retrofit") {
323
- const plan = retrofitPlan(report, direction);
324
- if (flags.out) {
325
- writeFileSync(resolve(io.cwd, flags.out), plan);
326
- io.out(`craft retrofit: ${report.actions.length} step${report.actions.length === 1 ? "" : "s"} for ${snap.url} in ${flags.out}`);
327
- } else io.out(plan);
328
- return 0;
329
- }
330
- io.out(flags.json ? toJson(report) : formatCharacter(report));
331
- if (flags.out) writeFileSync(resolve(io.cwd, flags.out), `${toJson(report)}
332
- `);
333
- return flags.strict && report.verdict !== "decided" ? 1 : 0;
334
- } catch (error) {
335
- io.err(`craft: ${error.message}`);
336
- return 2;
337
- }
338
- }
339
156
  export {
340
- formatCharacter,
341
- runReport
157
+ TELL_HEAVY,
158
+ characterReport
342
159
  };
@@ -1,22 +1,27 @@
1
+ import {
2
+ toJson
3
+ } from "./chunk-QIEDBL4J.js";
1
4
  import {
2
5
  CATALOGUE,
3
6
  CATALOGUE_VERSION,
4
7
  HOUSE_LOCKED,
5
8
  applyHouseGate,
6
9
  checkCopy,
10
+ holdHouseBlocks,
11
+ houseRule,
12
+ scanSource
13
+ } from "./chunk-WFB6F3BN.js";
14
+ import {
7
15
  compareCompetitor,
8
16
  compareFacts,
9
17
  extractCopy,
10
18
  fileKind,
11
19
  formatComparison,
12
20
  formatCompetitor,
13
- holdHouseBlocks,
14
- houseRule,
15
21
  pageCopy,
16
22
  protectedFacts,
17
- scanSource,
18
23
  visibleText
19
- } from "./chunk-LFNSB6W7.js";
24
+ } from "./chunk-4QWEAL4G.js";
20
25
 
21
26
  // src/character/config.ts
22
27
  var DEFAULT_IGNORE = [".claude", ".agents", ".cursor"];
@@ -80,12 +85,6 @@ function applySeverity(report, config) {
80
85
  return { ...report, findings, summary: { ...report.summary, blocking: findings.filter((f) => f.severity === "block").length } };
81
86
  }
82
87
 
83
- // src/character/json.ts
84
- var JSON_SCHEMA_VERSION = 1;
85
- function toJson(data) {
86
- return JSON.stringify({ schemaVersion: JSON_SCHEMA_VERSION, ...data }, null, 2);
87
- }
88
-
89
88
  // src/character/cli.ts
90
89
  import { execFileSync } from "child_process";
91
90
  import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "fs";
@@ -382,10 +381,16 @@ Usage
382
381
  craft direction research [--brief "<who, where, what>"] [--visual]
383
382
  craft direction propose [--snapshot <file>] [--estate <estate.json | dir>] [--out <file>]
384
383
  craft null build --brief "<text>" --out <dir> [--runs 20] [--parallel 4] [--model <name>]
384
+ craft null import <dir> --builder <name> --brief "<text>" [--out <dir>] [--model <name>]
385
+ craft null prompt --brief "<text>"
385
386
  craft estate add [<url | snapshot.json>] --id <id> [--client <name>] [--direction <art-direction.json>] [--estate <file>]
386
387
  craft estate compare [<url | snapshot.json | id>] [--null <dir>] [--directions] [--json] [--strict]
387
388
  craft report <url | snapshot.json> [--repo <dir>] [--null <dir>] [--estate <file>] [--direction <file>] [--json] [--strict]
388
389
  craft retrofit <url | snapshot.json> [the same] [--out RETROFIT.md]
390
+ craft calibrate <labels.json> [--out <dir>] [--fresh] [--json]
391
+ craft register list [--json]
392
+ craft register brief <plain|persuasive|warm|literary> [--json]
393
+ craft register check <file> --as <register> [--json]
389
394
 
390
395
  scan Markup, component code and stylesheets (source and compiled CSS).
391
396
  --staged reads the git index, for a pre-commit hook.
@@ -419,6 +424,10 @@ direction The site's art-direction.json: every choice with a reason from the
419
424
  sources' PNG photos and drafts choices for a person to confirm.
420
425
  null The counterfactual: about 20 pages \`claude -p\` builds from the brief
421
426
  alone, snapshotted and fingerprinted into null.json. Resumable.
427
+ import does the same for pages another builder made (v0, Lovable):
428
+ each an HTML file, or a folder holding a built index.html, served
429
+ on loopback so its asset paths resolve. prompt prints what to give
430
+ the builder, so its pages answer the same brief. Resumable.
422
431
  estate The register of shipped sites (estate.json). add fingerprints a site;
423
432
  compare lists the nearest, and marks siblings: two sites closer than
424
433
  two pages Claude builds for one brief. --strict exits 1 on a sibling.
@@ -427,6 +436,15 @@ report Every signal for one site: tells, typicality, the estate, the reasons.
427
436
  Anything not given is "not measured", and never counts as a pass.
428
437
  retrofit The report as a checklist: decide, then change type, colour, shape,
429
438
  effects, motion and copy. Never the page grammar.
439
+ calibrate How well the catalogue separates a labelled set (ai, human,
440
+ ai-looking): precision and recall per tell, and CHARACTER.md's
441
+ first three targets. --out keeps results.json and any snapshots it
442
+ took; --fresh takes every snapshot again. A page not measured is
443
+ listed, and never counts as a pass. A measure: always exit 0.
444
+ register Writing in a chosen register (REGISTERS.md). brief prints what to
445
+ do before drafting; check places a draft of five or more
446
+ paragraphs against the human baselines for that register. Never
447
+ fails: exit 0, or 2 on bad usage.
430
448
 
431
449
  ci options (scan, copy, audit)
432
450
  --baseline <file> Report only findings the baseline does not already
@@ -463,10 +481,11 @@ var VALUE_FLAGS = {
463
481
  "--viewport": "viewport",
464
482
  "--component": "component",
465
483
  "--competitor": "competitor",
466
- "--page": "page"
484
+ "--page": "page",
485
+ "--builder": "builder"
467
486
  };
468
487
  function parseFlags(args) {
469
- const flags = { positional: [], json: false, strict: false, staged: false, gate: false, updateBaseline: false, directions: false, visual: false };
488
+ const flags = { positional: [], json: false, strict: false, staged: false, gate: false, updateBaseline: false, directions: false, visual: false, fresh: false };
470
489
  for (let i = 0; i < args.length; i += 1) {
471
490
  const a = args[i];
472
491
  if (a === "--json") flags.json = true;
@@ -476,6 +495,7 @@ function parseFlags(args) {
476
495
  else if (a === "--update-baseline") flags.updateBaseline = true;
477
496
  else if (a === "--directions") flags.directions = true;
478
497
  else if (a === "--visual") flags.visual = true;
498
+ else if (a === "--fresh") flags.fresh = true;
479
499
  else if (a in VALUE_FLAGS) {
480
500
  const value = args[i + 1];
481
501
  i += 1;
@@ -580,7 +600,7 @@ async function pageSnapshot(target, cwd) {
580
600
  return readSnapshot(JSON.parse(readFileSync(local, "utf8")), target);
581
601
  }
582
602
  if (!/^https?:\/\//.test(target)) throw new Error(`${target} is neither a URL nor a snapshot file`);
583
- const { snapshotUrl } = await import("./audit-MTUC24XU.js");
603
+ const { snapshotUrl } = await import("./audit-4SFSLCKY.js");
584
604
  return snapshotUrl(target);
585
605
  }
586
606
  async function briefFor(flags, cwd) {
@@ -591,7 +611,7 @@ async function briefFor(flags, cwd) {
591
611
  if (typeof brief === "string" && brief.trim()) return brief;
592
612
  } else if (flags.direction) throw new Error(`no such file: ${flags.direction}`);
593
613
  if (flags.null) {
594
- const { loadNull } = await import("./cli-FLG3ZCAF.js");
614
+ const { loadNull } = await import("./cli-BN4IT6N2.js");
595
615
  return loadNull(flags.null, cwd).brief;
596
616
  }
597
617
  return void 0;
@@ -617,25 +637,31 @@ async function compareWithCompetitor(flags, io) {
617
637
  function run(argv, io) {
618
638
  const [command, ...rest] = argv;
619
639
  if (command === "direction") {
620
- return import("./cli-7OZCYOQY.js").then((m) => m.runDirection(rest, io));
640
+ return import("./cli-Y7Y5IROK.js").then((m) => m.runDirection(rest, io));
621
641
  }
622
642
  if (command === "report" || command === "retrofit") {
623
- return import("./cli-FCKHYAVZ.js").then((m) => m.runReport(command, rest, io));
643
+ return import("./cli-V44QEVS6.js").then((m) => m.runReport(command, rest, io));
644
+ }
645
+ if (command === "register") {
646
+ return import("./cli-JB4X5LAG.js").then((m) => m.runRegister(rest, io));
624
647
  }
625
648
  if (command === "estate") {
626
- return import("./cli-22TSWAX6.js").then((m) => m.runEstate(rest, io));
649
+ return import("./cli-GXIW7F3E.js").then((m) => m.runEstate(rest, io));
627
650
  }
628
651
  if (command === "null") {
629
- return import("./cli-FLG3ZCAF.js").then((m) => m.runNull(rest, io));
652
+ return import("./cli-BN4IT6N2.js").then((m) => m.runNull(rest, io));
653
+ }
654
+ if (command === "calibrate") {
655
+ return import("./cli-MDW7JTEF.js").then((m) => m.runCalibrate(rest, io));
630
656
  }
631
657
  if (command === "tells" && rest[0] === "harvest") {
632
- return import("./cli-FLG3ZCAF.js").then((m) => m.runHarvest(rest, io)).catch((error) => {
658
+ return import("./cli-BN4IT6N2.js").then((m) => m.runHarvest(rest, io)).catch((error) => {
633
659
  io.err(`craft: ${error.message}`);
634
660
  return 2;
635
661
  });
636
662
  }
637
663
  if (command === "snapshot" || command === "audit") {
638
- return import("./cli-5ACKICBO.js").then((m) => m.runAudit(command, rest, io));
664
+ return import("./cli-JZRQBCD4.js").then((m) => m.runAudit(command, rest, io));
639
665
  }
640
666
  if (!command || command === "help" || command === "--help" || command === "-h") {
641
667
  io.out(HELP);
@@ -722,7 +748,6 @@ function run(argv, io) {
722
748
 
723
749
  export {
724
750
  applySeverity,
725
- toJson,
726
751
  parseFlags,
727
752
  readPaths,
728
753
  loadConfig,
@@ -0,0 +1,9 @@
1
+ // src/character/json.ts
2
+ var JSON_SCHEMA_VERSION = 1;
3
+ function toJson(data) {
4
+ return JSON.stringify({ schemaVersion: JSON_SCHEMA_VERSION, ...data }, null, 2);
5
+ }
6
+
7
+ export {
8
+ toJson
9
+ };
@@ -4,14 +4,16 @@ import {
4
4
  formatDirectionMatches,
5
5
  summariseDirection,
6
6
  validateDirection
7
- } from "./chunk-YDURAOYR.js";
7
+ } from "./chunk-6TSDYETQ.js";
8
8
  import {
9
9
  loadNull
10
- } from "./chunk-RXXRXV3V.js";
10
+ } from "./chunk-ZUYERAFM.js";
11
+ import {
12
+ parseFlags
13
+ } from "./chunk-O5B5ELJH.js";
11
14
  import {
12
- parseFlags,
13
15
  toJson
14
- } from "./chunk-MUVFECFC.js";
16
+ } from "./chunk-QIEDBL4J.js";
15
17
  import {
16
18
  readSnapshot
17
19
  } from "./chunk-WUACK2HX.js";
@@ -26,7 +28,7 @@ import {
26
28
  groundName,
27
29
  hueName,
28
30
  shapeName
29
- } from "./chunk-LFNSB6W7.js";
31
+ } from "./chunk-WFB6F3BN.js";
30
32
 
31
33
  // src/estate/cli.ts
32
34
  import { existsSync, readFileSync, writeFileSync } from "fs";
@@ -103,7 +105,7 @@ async function snapshotOf(target, cwd) {
103
105
  return snap;
104
106
  }
105
107
  if (!/^https?:\/\//.test(target)) throw new Error(`${target} is neither a URL, a snapshot file, nor a site in the register`);
106
- const { snapshotUrl } = await import("./audit-MTUC24XU.js");
108
+ const { snapshotUrl } = await import("./audit-4SFSLCKY.js");
107
109
  return snapshotUrl(target);
108
110
  }
109
111
  var line = (distance, sibling, shared) => `${distance.toFixed(2)}${sibling ? " SIBLING" : ""}${shared.length ? ` shares ${shared.join(", ")}` : ""}`;
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  auditSnapshot,
6
6
  fingerprint
7
- } from "./chunk-LFNSB6W7.js";
7
+ } from "./chunk-WFB6F3BN.js";
8
8
  import {
9
9
  SNAPSHOT_VERSION
10
10
  } from "./chunk-QYBAVU3P.js";