@aglyn/plugins-ai 1.9.1 → 1.10.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.
Files changed (82) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-job-requests.d.ts +5 -0
  3. package/src/lib/components/ai-job-requests.js +4 -0
  4. package/src/lib/components/ai-job-requests.js.map +1 -1
  5. package/src/lib/components/ai-site-build-page.component.js +10 -3
  6. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  7. package/src/lib/components/ai-site-import-finish.component.d.ts +40 -0
  8. package/src/lib/components/ai-site-import-finish.component.js +174 -0
  9. package/src/lib/components/ai-site-import-finish.component.js.map +1 -0
  10. package/src/lib/components/ai-site-import-job.component.d.ts +11 -3
  11. package/src/lib/components/ai-site-import-job.component.js +220 -135
  12. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  13. package/src/lib/components/ai-site-import-start.component.d.ts +11 -2
  14. package/src/lib/components/ai-site-import-start.component.js +27 -5
  15. package/src/lib/components/ai-site-import-start.component.js.map +1 -1
  16. package/src/lib/components/ai-site-start-card.component.js +1 -1
  17. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  18. package/src/lib/jobs/ai-build-capabilities.js +2 -2
  19. package/src/lib/jobs/ai-build-capabilities.js.map +1 -1
  20. package/src/lib/jobs/ai-job-import-step.d.ts +2 -0
  21. package/src/lib/jobs/ai-job-import-step.js +31 -8
  22. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  23. package/src/lib/jobs/ai-job-page-language.d.ts +40 -2
  24. package/src/lib/jobs/ai-job-page-language.js +188 -9
  25. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  26. package/src/lib/jobs/ai-job-page-step.js +2 -0
  27. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  28. package/src/lib/jobs/ai-job-privacy-step.d.ts +5 -0
  29. package/src/lib/jobs/ai-job-privacy-step.js +9 -4
  30. package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
  31. package/src/lib/jobs/ai-job-text-step.d.ts +7 -1
  32. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  33. package/src/lib/jobs/ai-site-import-compile.d.ts +13 -2
  34. package/src/lib/jobs/ai-site-import-compile.js +115 -21
  35. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  36. package/src/lib/jobs/ai-site-import-document.d.ts +5 -1
  37. package/src/lib/jobs/ai-site-import-document.js +5 -1
  38. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  39. package/src/lib/jobs/ai-site-import-look.d.ts +16 -4
  40. package/src/lib/jobs/ai-site-import-look.js +54 -13
  41. package/src/lib/jobs/ai-site-import-look.js.map +1 -1
  42. package/src/lib/jobs/ai-site-import-wording.d.ts +187 -0
  43. package/src/lib/jobs/ai-site-import-wording.js +747 -0
  44. package/src/lib/jobs/ai-site-import-wording.js.map +1 -0
  45. package/src/lib/layout-language/ai-layout-compiler.d.ts +12 -1
  46. package/src/lib/layout-language/ai-layout-compiler.js +29 -30
  47. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  48. package/src/lib/layout-language/ai-layout-language.d.ts +12 -0
  49. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  50. package/src/lib/model/ai-site-import-fidelity.d.ts +211 -2
  51. package/src/lib/model/ai-site-import-fidelity.js +1011 -14
  52. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  53. package/src/lib/model/ai-site-import-report.d.ts +52 -1
  54. package/src/lib/model/ai-site-import-report.js +102 -5
  55. package/src/lib/model/ai-site-import-report.js.map +1 -1
  56. package/src/lib/model/ai-site-import-view.d.ts +62 -2
  57. package/src/lib/model/ai-site-import-view.js +83 -4
  58. package/src/lib/model/ai-site-import-view.js.map +1 -1
  59. package/src/lib/model/ai-site-import.d.ts +122 -6
  60. package/src/lib/model/ai-site-import.js +202 -9
  61. package/src/lib/model/ai-site-import.js.map +1 -1
  62. package/src/lib/model/ai-site-look.d.ts +51 -0
  63. package/src/lib/model/ai-site-look.js +205 -29
  64. package/src/lib/model/ai-site-look.js.map +1 -1
  65. package/src/lib/runtime/ai-doctrine-validators.d.ts +19 -0
  66. package/src/lib/runtime/ai-doctrine-validators.js +25 -0
  67. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  68. package/src/lib/runtime/ai-doctrine.js +4 -1
  69. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  70. package/src/lib/server/ai-allotments.js +4 -2
  71. package/src/lib/server/ai-allotments.js.map +1 -1
  72. package/src/lib/server/ai-jobs-resume.js +32 -5
  73. package/src/lib/server/ai-jobs-resume.js.map +1 -1
  74. package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +36 -10
  75. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +48 -4
  76. package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
  77. package/src/lib/site-import/fixtures/site-look-slate.d.ts +27 -0
  78. package/src/lib/site-import/fixtures/site-look-slate.js +29 -0
  79. package/src/lib/site-import/fixtures/site-look-slate.js.map +1 -0
  80. package/src/lib/site-import/site-import-layout.d.ts +19 -5
  81. package/src/lib/site-import/site-import-layout.js +137 -16
  82. package/src/lib/site-import/site-import-layout.js.map +1 -1
@@ -44,6 +44,14 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
44
44
  * the kind of a group the reader could not tell, an alignment. A page of
45
45
  * a collection, and any page whose answer is missing, is drawn from the
46
46
  * layout with no model.
47
+ * 4. How the owner asked the site FINISHED (AGL-4152). Keep my site, the
48
+ * default for an import that asked nothing, is the above held tighter:
49
+ * the source's alignment, its boxing and its heading's measure, whatever
50
+ * the answer says. Improve it frees the layout: the answer's bands and
51
+ * alignment on every section, the site's band rhythm, the theme's widths,
52
+ * any hero, any group's kind and style, like runs of lines as cards.
53
+ * Either way every word, picture, icon, button, heading, form and film
54
+ * is the source's.
47
55
  *
48
56
  * A read made before the reader kept no layout: its page is read into one
49
57
  * here, from its lines, one section at each second-level heading.
@@ -362,6 +370,28 @@ const num = (value)=>value === undefined ? Number.NaN : Number.parseFloat(value)
362
370
  'list',
363
371
  'text'
364
372
  ]);
373
+ /**
374
+ * The groups that keep their kind even on a page its owner asked improved
375
+ * (AGL-4152): a quote's words and a strip of logos have no place in a card's
376
+ * title or a step's, and would stop being what they are; questions and
377
+ * answers stay questions a visitor opens, and plans stay plan cards. The 11/4
378
+ * eval's answers redrew five pages' questions as cards.
379
+ */ const FIXED_KINDS = new Set([
380
+ 'quotes',
381
+ 'logos',
382
+ 'faq',
383
+ 'pricing'
384
+ ]);
385
+ /** The styles that box a group's items, and the ones that leave them open: Keep my site keeps a group's own (AGL-4152). */ const BOXED_STYLES = new Set([
386
+ 'cards',
387
+ 'articles'
388
+ ]);
389
+ const OPEN_STYLES = new Set([
390
+ 'ruled',
391
+ 'icons',
392
+ 'pictures'
393
+ ]);
394
+ /** The fewest like items a run of lines needs to be drawn as cards, on a page its owner asked improved (AGL-4152). */ const LIKE_ITEMS_AS_CARDS = 3;
365
395
  /** The hero each place of the source's picture opens as, where no answer chose one. */ const HERO_FOR = {
366
396
  beside: 'split',
367
397
  behind: 'cover',
@@ -753,13 +783,32 @@ const HEX = /^#[0-9a-f]{6}$/i;
753
783
  rule: ruleOf(group.rule, scope.layout.look)
754
784
  } : {});
755
785
  }
756
- /** The style an answer chose, where the group can be drawn so: pictures need a picture on every item, icons an icon. */ function styleFor(asked, group, items) {
786
+ /**
787
+ * The style an answer chose, where the group can be drawn so: pictures need a
788
+ * picture on every item, icons an icon. A page kept as it is keeps the
789
+ * source's boxing (AGL-4152): a boxed group takes only a boxed style, an open
790
+ * one only an open style.
791
+ */ function styleFor(asked, group, items, finish) {
757
792
  const fallback = defaultStyle(group, items);
758
793
  if (!asked || !AI_LAYOUT_GROUP_STYLES.includes(asked)) return fallback;
794
+ if (finish !== 'improve' && !(group.boxed ? BOXED_STYLES : OPEN_STYLES).has(asked)) return fallback;
759
795
  if ((asked === 'pictures' || asked === 'articles') && !items.every((item)=>item.picture)) return fallback;
760
796
  if (asked === 'icons' && !items.every((item)=>item.iconPath)) return fallback;
761
797
  return asked;
762
798
  }
799
+ /**
800
+ * Whether a run of lines that only share a shape reads as cards (AGL-4152):
801
+ * three or more items, each showing the same parts and led by its own title,
802
+ * with no heading among an item's lines but its title, so every heading of
803
+ * the source is still a heading.
804
+ */ function likeItems(scope, group) {
805
+ if (group.items.length < LIKE_ITEMS_AS_CARDS) return false;
806
+ if (new Set(group.items.map((item)=>itemShape(item).join(' + '))).size !== 1) return false;
807
+ return group.items.every((item)=>item.title !== undefined && item.lines.every((ref)=>{
808
+ var _scope_doc_blocks_ref;
809
+ return ref === item.title || ((_scope_doc_blocks_ref = scope.doc.blocks[ref]) == null ? void 0 : _scope_doc_blocks_ref.kind) !== 'heading';
810
+ }));
811
+ }
763
812
  /** The longest line that leads a figure: "1-click", "$0.83". */ const FIGURE_MAX_CHARS = 14;
764
813
  /**
765
814
  * Whether a group can be drawn as figures (AGL-4083): each item a short line
@@ -782,8 +831,10 @@ const HEX = /^#[0-9a-f]{6}$/i;
782
831
  var _scope_answer;
783
832
  const answer = (_ref = (_scope_answer = scope.answer) == null ? void 0 : _scope_answer.groups[scope.groupAt]) != null ? _ref : null;
784
833
  scope.groupAt += 1;
785
- // Rows the source sets are drawn as its rows: no answer's kind or style is one of them (AGL-4083).
786
- if (group.inline) {
834
+ const improve = scope.finish === 'improve';
835
+ // Rows the source sets are drawn as its rows: no answer's kind or style is one of them (AGL-4083). On a
836
+ // page its owner asked improved, a kind the answer names is (AGL-4152); a style alone has nothing to draw in rows.
837
+ if (group.inline && !(improve && (answer == null ? void 0 : answer.kind))) {
787
838
  if ((answer == null ? void 0 : answer.kind) || (answer == null ? void 0 : answer.style)) scope.settled.push({
788
839
  at: scope.at,
789
840
  what: `a ${group.group} group drawn as the source's rows`
@@ -797,7 +848,16 @@ const HEX = /^#[0-9a-f]{6}$/i;
797
848
  }
798
849
  ];
799
850
  }
800
- const asked = (answer == null ? void 0 : answer.kind) && OPEN_KINDS.has(group.group) ? answer.kind : group.group;
851
+ // A page its owner asked improved reads any group as the answer does (AGL-4152), but a quote, a logo, a question or a plan.
852
+ const opens = improve ? !FIXED_KINDS.has(group.group) : OPEN_KINDS.has(group.group);
853
+ const answered = (answer == null ? void 0 : answer.kind) && opens ? answer.kind : group.group;
854
+ // Lines that only share a shape, three or more alike, are cards on a page its owner asked improved (AGL-4152).
855
+ const carded = improve && answered === 'text' && likeItems(scope, group);
856
+ if (carded) scope.settled.push({
857
+ at: scope.at,
858
+ what: `${group.items.length} like runs of lines drawn as cards`
859
+ });
860
+ const asked = carded ? 'cards' : answered;
801
861
  // A list is one line an item (AGL-4083): one asked of items with more would
802
862
  // join a label to its value, and 49 of a plan's rows lost theirs so on 11/1.
803
863
  const joins = asked === 'list' && group.group !== 'list' && group.items.some((item)=>item.lines.length > 1);
@@ -811,7 +871,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
811
871
  at: scope.at,
812
872
  what: `a ${group.group} group kept as it is: its items hold more than a figure can show`
813
873
  });
814
- else if (kind !== group.group) scope.settled.push({
874
+ else if (kind !== group.group && !carded) scope.settled.push({
815
875
  at: scope.at,
816
876
  what: `a ${group.group} group drawn as ${kind}, as its design answer read it`
817
877
  });
@@ -900,6 +960,8 @@ const HEX = /^#[0-9a-f]{6}$/i;
900
960
  ] : [];
901
961
  }
902
962
  const items = group.items.map((item)=>itemOf(scope, group, item, kind));
963
+ // Whether the items are boxed: the source's, or on a page its owner asked improved, the answer's style (AGL-4152).
964
+ const boxed = improve && (answer == null ? void 0 : answer.style) ? BOXED_STYLES.has(answer.style) : group.boxed;
903
965
  if (kind === 'quotes') {
904
966
  // The reader names a quote's words its title and who said it its text.
905
967
  const quotes = items.map((item)=>{
@@ -923,7 +985,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
923
985
  return item;
924
986
  }),
925
987
  columns
926
- }, group.boxed ? {
988
+ }, boxed ? {
927
989
  variant: 'cards'
928
990
  } : {
929
991
  style: 'quiet'
@@ -942,11 +1004,12 @@ const HEX = /^#[0-9a-f]{6}$/i;
942
1004
  kind: 'stats',
943
1005
  items,
944
1006
  columns
945
- }, group.boxed ? {
1007
+ }, boxed ? {
946
1008
  variant: 'cards'
947
1009
  } : {}, drawnAs(scope, group))
948
1010
  ];
949
- const style = joins ? 'ruled' : styleFor(answer == null ? void 0 : answer.style, group, items);
1011
+ // A group kept apart from a list is ruled, where its boxing allows (AGL-4152).
1012
+ const style = styleFor(joins ? 'ruled' : answer == null ? void 0 : answer.style, group, items, scope.finish);
950
1013
  return [
951
1014
  _extends({
952
1015
  kind: kind === 'steps' ? 'steps' : 'cards',
@@ -1258,7 +1321,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1258
1321
  * answer never repaints a section's own band. Nor does it move the picture
1259
1322
  * (AGL-4138): a picture under centered words stays under them, as a picture
1260
1323
  * beside the words stays beside them.
1261
- */ function heroOf(section, index, answer, settled) {
1324
+ */ function heroOf(section, index, answer, settled, drawn) {
1262
1325
  var _ref;
1263
1326
  var _section_hero;
1264
1327
  if (index !== 0 || !((_section_hero = section.hero) == null ? void 0 : _section_hero.picture)) return undefined;
@@ -1266,14 +1329,16 @@ const HEX = /^#[0-9a-f]{6}$/i;
1266
1329
  if ((answer == null ? void 0 : answer.hero) === 'none') return undefined;
1267
1330
  const place = section.hero.picture;
1268
1331
  const own = HERO_FOR[place];
1269
- if ((answer == null ? void 0 : answer.hero) && DIMMED_HEROES.has(answer.hero) && section.band !== 'dark' && place !== 'behind') {
1332
+ // Dimmed words need a dark ground: the section's own, or on a page its owner asked improved, the answer's (AGL-4152).
1333
+ if ((answer == null ? void 0 : answer.hero) && DIMMED_HEROES.has(answer.hero) && drawn.band !== 'dark' && place !== 'behind') {
1270
1334
  settled.push({
1271
1335
  at: 'sections[0]',
1272
1336
  what: `the ${answer.hero} hero set aside: the section keeps its own lighter ground`
1273
1337
  });
1274
1338
  return own;
1275
1339
  }
1276
- if ((answer == null ? void 0 : answer.hero) && !HEROES_AT[place].has(answer.hero)) {
1340
+ // The picture stays where the source lays it, unless the owner asked the page improved (AGL-4152).
1341
+ if ((answer == null ? void 0 : answer.hero) && drawn.finish !== 'improve' && !HEROES_AT[place].has(answer.hero)) {
1277
1342
  settled.push({
1278
1343
  at: 'sections[0]',
1279
1344
  what: `the ${answer.hero} hero set aside: the source lays its picture ${place} its words`
@@ -1282,6 +1347,19 @@ const HEX = /^#[0-9a-f]{6}$/i;
1282
1347
  }
1283
1348
  return (_ref = answer == null ? void 0 : answer.hero) != null ? _ref : own;
1284
1349
  }
1350
+ /** How a page is finished (AGL-4152): the finish asked of it, else its document's, else kept as it is. */ export function aiSiteImportFinishOf(doc, asked) {
1351
+ const finish = asked != null ? asked : doc == null ? void 0 : doc.finish;
1352
+ return finish === 'improve' ? 'improve' : 'keep';
1353
+ }
1354
+ /**
1355
+ * The Container width a source holds its opening's heading to (AGL-4152):
1356
+ * the theme's breakpoint nearest its measure, at most a page's own, which an
1357
+ * opening's words may span; none where the source sets none.
1358
+ */ export function aiSiteImportHeroMeasure(section) {
1359
+ var _section_hero;
1360
+ const step = siteImportWidthOf((_section_hero = section.hero) == null ? void 0 : _section_hero.measure);
1361
+ return step === 'xl' ? 'lg' : step;
1362
+ }
1285
1363
  /**
1286
1364
  * The page's sections in the layout language (AGL-4107): the source's layout,
1287
1365
  * each section in its own band (or the answer's, where the source gave none),
@@ -1291,6 +1369,8 @@ const HEX = /^#[0-9a-f]{6}$/i;
1291
1369
  */ export function aiSiteImportDesignedSections(doc, answer, options = {}) {
1292
1370
  var _options_formId;
1293
1371
  const layout = aiSiteImportLayoutOf(doc);
1372
+ const finish = aiSiteImportFinishOf(doc, options.finish);
1373
+ const improve = finish === 'improve';
1294
1374
  const scope = {
1295
1375
  doc,
1296
1376
  layout,
@@ -1313,7 +1393,8 @@ const HEX = /^#[0-9a-f]{6}$/i;
1313
1393
  settled: [],
1314
1394
  at: '',
1315
1395
  films: filmsOf(doc),
1316
- film: null
1396
+ film: null,
1397
+ finish
1317
1398
  };
1318
1399
  const backdropOf = (section)=>{
1319
1400
  var _section_backdrop;
@@ -1321,7 +1402,7 @@ const HEX = /^#[0-9a-f]{6}$/i;
1321
1402
  };
1322
1403
  const pageFilm = layout.sections.reduce((found, section)=>found != null ? found : firstFilm(scope, section.nodes), null);
1323
1404
  const sections = layout.sections.map((section, index)=>{
1324
- var _ref, _firstFilm, _ref1, _siteImportWidthOf;
1405
+ var _ref, _firstFilm, _ref1, _ref2;
1325
1406
  const given = (_ref = answer == null ? void 0 : answer.sections[index]) != null ? _ref : null;
1326
1407
  scope.answer = given;
1327
1408
  scope.groupAt = 0;
@@ -1358,22 +1439,32 @@ const HEX = /^#[0-9a-f]{6}$/i;
1358
1439
  line: ref
1359
1440
  }));
1360
1441
  }
1361
- const hero = heroOf(section, index, given, scope.settled);
1362
- // A band only where the source gave the section none of its own.
1363
- const band = section.background === null && !section.backdrop && (given == null ? void 0 : given.band) ? given.band : section.band;
1442
+ // A band only where the source gave the section none of its own; any section's, on a page its owner asked improved (AGL-4152).
1443
+ const band = (given == null ? void 0 : given.band) && (improve || section.background === null && !section.backdrop) ? given.band : section.band;
1444
+ const hero = heroOf(section, index, given, scope.settled, {
1445
+ band: improve ? band : section.band,
1446
+ finish
1447
+ });
1364
1448
  // A long read is set at the start, as text is read, whatever its source centers.
1365
1449
  const reading = blocks.filter((block)=>block.kind === 'text').length > READING_PARAGRAPHS;
1450
+ const source = reading ? 'start' : section.align;
1451
+ // The source's own heading measure for its opening's words, on a page kept as it is (AGL-4152).
1452
+ const measure = hero && !improve ? aiSiteImportHeroMeasure(section) : null;
1366
1453
  return _extends({
1367
1454
  band,
1368
- align: (_ref1 = given == null ? void 0 : given.align) != null ? _ref1 : reading ? 'start' : section.align,
1369
- // As wide as the source runs (AGL-4083); where it sets no cap, a page's width, a long read's measure.
1370
- width: (_siteImportWidthOf = siteImportWidthOf(section.width)) != null ? _siteImportWidthOf : reading ? 'md' : 'lg'
1455
+ // Kept as it is, a section keeps the source's alignment (AGL-4152); improved, the answer's.
1456
+ align: improve ? (_ref1 = given == null ? void 0 : given.align) != null ? _ref1 : source : source,
1457
+ // As wide as the source runs (AGL-4083), or the theme's own on a page its owner asked improved (AGL-4152);
1458
+ // where it sets no cap, a page's width, a long read's measure.
1459
+ width: (_ref2 = improve ? null : siteImportWidthOf(section.width)) != null ? _ref2 : reading ? 'md' : 'lg'
1371
1460
  }, row.cols && blocks.some((block)=>block.col !== undefined) ? {
1372
1461
  cols: row.cols
1373
1462
  } : {}, {
1374
1463
  blocks: mergeLists(blocks)
1375
1464
  }, hero ? {
1376
1465
  hero
1466
+ } : {}, measure ? {
1467
+ measure
1377
1468
  } : {});
1378
1469
  });
1379
1470
  return {
@@ -1392,14 +1483,17 @@ const HEX = /^#[0-9a-f]{6}$/i;
1392
1483
  var _compiled_videoIds;
1393
1484
  const { doc } = input;
1394
1485
  const formId = input.targets.forms.length === 1 ? input.targets.forms[0].id : null;
1486
+ const finish = aiSiteImportFinishOf(doc, input.finish);
1395
1487
  const designed = aiSiteImportDesignedSections(doc, (_input_answer = input.answer) != null ? _input_answer : null, {
1396
- formId
1488
+ formId,
1489
+ finish
1397
1490
  });
1398
1491
  const compile = (sections)=>aiCompileLayoutPage(sections, input.plan, input.targets, _extends({
1399
1492
  // A page brought in draws its repeats as its source does (AGL-4107).
1400
1493
  reusableComponents: false,
1401
1494
  sectionIds: input.sectionIds,
1402
- verbatim: true
1495
+ verbatim: true,
1496
+ finish
1403
1497
  }, input.design ? {
1404
1498
  design: input.design
1405
1499
  } : {}, input.language ? {