@aglyn/plugins-ai 1.20.3 → 1.22.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.
@@ -219,9 +219,14 @@ export interface SiteImportImprovedFidelity {
219
219
  facts: SiteImportImprovedLine & {
220
220
  missing: string[];
221
221
  };
222
- /** Facts and names on the page that nothing the import read says: none. */
222
+ /**
223
+ * Facts and names on the page that nothing the import read says: none.
224
+ * `at` is the line each was found in, cut short around it (AGL-4152), so
225
+ * a re-ask and a later read of the job can tell which sentence held it.
226
+ */
223
227
  invented: SiteImportImprovedLine & {
224
228
  found: string[];
229
+ at?: string[];
225
230
  };
226
231
  /** Every thing that must land, on the page. */
227
232
  held: SiteImportImprovedLine & {
@@ -498,6 +503,14 @@ export declare function siteImportFactScope(sourceTexts: readonly string[], voca
498
503
  * wording pass holds each line it rewrites (`ai-site-import-wording.ts`).
499
504
  */
500
505
  export declare function siteImportFactTokens(text: string, scope: SiteImportFactScope, own: boolean): string[];
506
+ /** The most characters a line an invented fact sat in is kept at (AGL-4152). */
507
+ export declare const SITE_IMPORT_INVENTED_LINE_CHARS = 120;
508
+ /**
509
+ * A line cut short around what it says (AGL-4152): whole where it is short,
510
+ * else the `SITE_IMPORT_INVENTED_LINE_CHARS` around the first place it says
511
+ * `what`, an ellipsis where it was cut.
512
+ */
513
+ export declare function siteImportLineAround(text: string, what: string, most?: number): string;
501
514
  /** A built header and footer, scored against the source's. */
502
515
  export interface SiteImportFrameFidelity {
503
516
  /** The lowest ratio of the header's and footer's measures. */
@@ -2289,6 +2289,19 @@ const isHeading = (node)=>{
2289
2289
  if (xs) return Number(xs) < 6;
2290
2290
  return !/\b(?:sm|md|lg):/.test(size) && size.trim() !== '' && Number(size) < 6;
2291
2291
  };
2292
+ /** The most characters a line an invented fact sat in is kept at (AGL-4152). */ export const SITE_IMPORT_INVENTED_LINE_CHARS = 120;
2293
+ /**
2294
+ * A line cut short around what it says (AGL-4152): whole where it is short,
2295
+ * else the `SITE_IMPORT_INVENTED_LINE_CHARS` around the first place it says
2296
+ * `what`, an ellipsis where it was cut.
2297
+ */ export function siteImportLineAround(text, what, most = SITE_IMPORT_INVENTED_LINE_CHARS) {
2298
+ const line = clean(text);
2299
+ if (line.length <= most) return line;
2300
+ const found = line.toLowerCase().indexOf(what.toLowerCase());
2301
+ const room = most - 2;
2302
+ const start = Math.max(0, Math.min(found < 0 ? 0 : found - Math.floor(room / 2), line.length - room));
2303
+ return `${start > 0 ? '…' : ''}${line.slice(start, start + room).trim()}${start + room < line.length ? '…' : ''}`;
2304
+ }
2292
2305
  /** The kept ledger and the design lines of a page a generative Improve it built (AGL-4152). */ function improvedScore(source, built, look, drawnSections, options) {
2293
2306
  var _options_scope, _options_vocabulary, _source_photos, _options_forms, _options_destinations, _options_meaning, _source_photos1, _ref, _look_theme_button_fill;
2294
2307
  const ledger = siteImportLedger(_extends({
@@ -2326,6 +2339,15 @@ const isHeading = (node)=>{
2326
2339
  const found = [
2327
2340
  ...new Set(shown.flatMap((text)=>siteImportFactTokens(text, scope, true)))
2328
2341
  ].filter((token)=>!allowed.has(token) && token !== 'name:FAQ' && token !== 'name:FAQs');
2342
+ // The line each was found in, cut short around it (AGL-4152): never the page whole.
2343
+ const inventedAt = [
2344
+ ...new Set(found.slice(0, 8).flatMap((token)=>{
2345
+ const text = shown.find((entry)=>siteImportFactTokens(entry, scope, true).includes(token));
2346
+ return text ? [
2347
+ siteImportLineAround(text, token.slice(token.indexOf(':') + 1))
2348
+ ] : [];
2349
+ }))
2350
+ ];
2329
2351
  // Held: every thing that must land, on the page.
2330
2352
  const photoOf = new Map(((_source_photos = source.photos) != null ? _source_photos : []).flatMap((photo)=>photo.from ? [
2331
2353
  [
@@ -2395,7 +2417,9 @@ const isHeading = (node)=>{
2395
2417
  }),
2396
2418
  invented: _extends({}, line(found.length ? 0 : 1, 1), {
2397
2419
  found: found.slice(0, 8)
2398
- }),
2420
+ }, inventedAt.length ? {
2421
+ at: inventedAt
2422
+ } : {}),
2399
2423
  held: _extends({}, line(musts.length - missingHeld.length, musts.length), {
2400
2424
  missing: missingHeld
2401
2425
  }),