@aglyn/plugins-ai 1.15.0 → 1.15.2
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.
- package/package.json +17 -17
- package/src/lib/components/ai-site-import-start.component.js +3 -1
- package/src/lib/components/ai-site-import-start.component.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.d.ts +18 -2
- package/src/lib/jobs/ai-job-import-step.js +24 -8
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.d.ts +2 -0
- package/src/lib/jobs/ai-job-page-language.js +72 -37
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.js +5 -3
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-job-text-step.d.ts +1 -0
- package/src/lib/jobs/ai-job-text-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +26 -1
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-improve.d.ts +59 -6
- package/src/lib/jobs/ai-site-import-improve.js +149 -19
- package/src/lib/jobs/ai-site-import-improve.js.map +1 -1
- package/src/lib/jobs/ai-site-import-plan.js +1 -1
- package/src/lib/jobs/ai-site-import-plan.js.map +1 -1
- package/src/lib/model/ai-credit-estimate.d.ts +16 -0
- package/src/lib/model/ai-credit-estimate.js +14 -0
- package/src/lib/model/ai-credit-estimate.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +2 -0
- package/src/lib/model/ai-site-import-fidelity.js +7 -1
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import-view.d.ts +3 -1
- package/src/lib/model/ai-site-import-view.js +8 -3
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +27 -2
- package/src/lib/model/ai-site-import.js +63 -14
- package/src/lib/model/ai-site-import.js.map +1 -1
|
@@ -18,11 +18,11 @@ import type { AiLayoutDesign } from '../layout-language/ai-layout-design';
|
|
|
18
18
|
import { type AiLayoutImportHero, type AiLayoutItem, type AiLayoutSettlement } from '../layout-language/ai-layout-language';
|
|
19
19
|
import type { AiSiteImportAddedSection, AiSiteImportPagePictures, AiSiteImportPageRole, AiSiteImportPlan } from '../model/ai-site-import';
|
|
20
20
|
import { type SiteImportFidelityTheme, type SiteImportPageFidelity } from '../model/ai-site-import-fidelity';
|
|
21
|
-
import { type SiteImportLedger } from '../model/ai-site-import-ledger';
|
|
21
|
+
import { type SiteImportLedger, type SiteImportLedgerLine } from '../model/ai-site-import-ledger';
|
|
22
22
|
import type { AiSystemBlock, AiTool, AiUsage } from '../providers/contract';
|
|
23
23
|
import type { AiGenerationCheck } from '../runtime/ai-doctrine';
|
|
24
24
|
import type { AiCopyFraming, AiDoctrineViolation } from '../runtime/ai-doctrine-validators';
|
|
25
|
-
import { type AiSiteImportImprovedSection } from './ai-site-import-honesty';
|
|
25
|
+
import { type AiSiteImportImprovedBlock, type AiSiteImportImprovedSection } from './ai-site-import-honesty';
|
|
26
26
|
import { type AiSiteImportDesigned } from './ai-site-import-compile';
|
|
27
27
|
import { type AiSiteImportDocument } from './ai-site-import-document';
|
|
28
28
|
/** The answer's kind of generation: the name its re-ask and its doctrine scope go by. */
|
|
@@ -52,6 +52,13 @@ export declare const AI_SITE_IMPORT_IMPROVE_DIGEST_CHARS = 16000;
|
|
|
52
52
|
export declare function aiSiteImportImproveInstructions(digest: string): readonly AiSystemBlock[];
|
|
53
53
|
/** The most characters a page's ledger shows. */
|
|
54
54
|
export declare const AI_SITE_IMPORT_LEDGER_MAX_CHARS = 16000;
|
|
55
|
+
/**
|
|
56
|
+
* The lines each picture of a page stands with (AGL-4152): the words after it
|
|
57
|
+
* in its section, up to the next picture, as a row of pictured services or a
|
|
58
|
+
* photo over its caption lays them out. What the ledger tells a redesign a
|
|
59
|
+
* picture goes with, and what a card written of those words is given it by.
|
|
60
|
+
*/
|
|
61
|
+
export declare function aiSiteImportPictureCaptions(ledger: Pick<SiteImportLedger, 'items' | 'lines'>): Map<string, SiteImportLedgerLine[]>;
|
|
55
62
|
/**
|
|
56
63
|
* A page's ledger as its answer reads it (AGL-4152): what it may place, where
|
|
57
64
|
* each link goes, and every line it rewrites, numbered. Uncached, per page, and
|
|
@@ -79,9 +86,13 @@ export declare function aiSiteImportImprovePrompt(input: {
|
|
|
79
86
|
}): string;
|
|
80
87
|
/**
|
|
81
88
|
* How many new sections a page of each role is asked for (AGL-4152): a home
|
|
82
|
-
* or a main service page two, a contact page none, its form framed instead
|
|
89
|
+
* or a main service page two, a contact page none, its form framed instead,
|
|
90
|
+
* and a gallery none: its pictures are what it is for, and a section added
|
|
91
|
+
* to a page of photos only stands between a visitor and them.
|
|
83
92
|
*/
|
|
84
93
|
export declare const AI_SITE_IMPORT_NEW_SECTIONS: Readonly<Record<AiSiteImportPageRole, number>>;
|
|
94
|
+
/** The fewest content words an old section says for a new one to be its rework (AGL-4152): fewer is a label, which any section may echo. */
|
|
95
|
+
export declare const AI_SITE_IMPORT_REWORK_LEAST_WORDS = 4;
|
|
85
96
|
/** The most sections a redesigned page runs to: a page the source already fills has no room for more. */
|
|
86
97
|
export declare const AI_SITE_IMPORT_IMPROVE_MOST_SECTIONS = 10;
|
|
87
98
|
/** What a page is for, as its plan says, else from its address and what it holds. */
|
|
@@ -102,7 +113,9 @@ export declare function aiSiteImportImproveRoleLines(input: {
|
|
|
102
113
|
* its own, and the rework of no section of the old page. Each section of the
|
|
103
114
|
* old page past its opening is reworked by the one section that says most
|
|
104
115
|
* of it; another section drawing on its words, such as a why-us of the
|
|
105
|
-
* opening's facts, is new.
|
|
116
|
+
* opening's facts, is new. An old section of a few words, a heading over a
|
|
117
|
+
* band or a label over a kept group, reworks nothing: any new section that
|
|
118
|
+
* happens to say its two or three words would otherwise read as its rework.
|
|
106
119
|
*/
|
|
107
120
|
export declare function aiSiteImportImproveNewSections(answer: readonly AiSiteImportImprovedSection[], ledger: Pick<SiteImportLedger, 'lines' | 'items'>): number[];
|
|
108
121
|
/** What a redesign is asked to be, by its role (AGL-4152). */
|
|
@@ -125,8 +138,18 @@ export declare function aiSiteImportImprovePlanMisses(answer: readonly AiSiteImp
|
|
|
125
138
|
}): AiDoctrineViolation[];
|
|
126
139
|
/** A redesign's answer, read by position: `null` where it gave no section it can draw. */
|
|
127
140
|
export declare function aiReadImprovedPage(raw: unknown, settled?: AiLayoutSettlement[]): AiSiteImportImprovedSection[] | null;
|
|
128
|
-
/** The
|
|
129
|
-
export declare
|
|
141
|
+
/** The least width over height of an opening photo a redesign lays its words over (AGL-4152): a landscape, not a square or a portrait. */
|
|
142
|
+
export declare const AI_SITE_IMPORT_COVER_LEAST_RATIO = 1.3;
|
|
143
|
+
/**
|
|
144
|
+
* The site's hero as a page brought in draws it: a collage or a portrait holds
|
|
145
|
+
* what a page brought in does not. A redesign whose opening holds the page's
|
|
146
|
+
* own landscape photo lays its words over it (AGL-4152): a hero that boxes a
|
|
147
|
+
* wide photo under centered words reads as a picture pasted below a heading,
|
|
148
|
+
* the way an old page looks, never as a brand's opening.
|
|
149
|
+
*/
|
|
150
|
+
export declare function aiSiteImportImproveHero(design: AiLayoutDesign, plan?: AiSiteImportPlan | null, opening?: {
|
|
151
|
+
ratio?: number;
|
|
152
|
+
} | null): AiLayoutImportHero;
|
|
130
153
|
/** How many of a group's items sit across: planned for how much each says. */
|
|
131
154
|
export declare function aiSiteImportImproveColumns(items: readonly AiLayoutItem[]): number;
|
|
132
155
|
export interface AiSiteImportImproveCompileInput {
|
|
@@ -139,6 +162,16 @@ export interface AiSiteImportImproveCompileInput {
|
|
|
139
162
|
/** The theme the page is drawn in, where it is known: a brand band only where the brand itself fills. */
|
|
140
163
|
theme?: SiteImportFidelityTheme | null;
|
|
141
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* The source's own pictures each set of written cards takes (AGL-4152), by
|
|
167
|
+
* block: where an answer wrote like services as cards and gave none of them a
|
|
168
|
+
* picture, while the page's photos of those same services sit unplaced, each
|
|
169
|
+
* card takes the photo whose words it says. Every card must find one, or the
|
|
170
|
+
* set takes none: a grid of cards half of which show a photo reads as broken.
|
|
171
|
+
* Where no card says a photo's words but the one section's unplaced photos
|
|
172
|
+
* number exactly the cards, they are taken in order, as the source laid them.
|
|
173
|
+
*/
|
|
174
|
+
export declare function aiSiteImportCardPictures(answer: readonly AiSiteImportImprovedSection[], ledger: Pick<SiteImportLedger, 'items' | 'lines'>): Map<AiSiteImportImprovedBlock, string[]>;
|
|
142
175
|
/** What a redesign compiles into, and what its row and its check say of it. */
|
|
143
176
|
export interface AiSiteImportImprovedPage {
|
|
144
177
|
given: AiSiteImportDesigned;
|
|
@@ -201,7 +234,21 @@ export declare function aiSiteImportImproveReaskTokens(input: {
|
|
|
201
234
|
export interface AiSiteImportImproved<T> {
|
|
202
235
|
built: T;
|
|
203
236
|
page: AiSiteImportImprovedPage;
|
|
237
|
+
/** The design lines it was taken with still missed, by code (`AI_SITE_IMPORT_IMPROVE_SOFT_CODES`): only where no re-ask was left. */
|
|
238
|
+
missed?: string[];
|
|
204
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* What a redesign may still miss when no re-ask is left and be taken all the
|
|
242
|
+
* same (AGL-4152): how it is planned and drawn, never what it says or holds.
|
|
243
|
+
* Each is asked for in the one re-ask where it can be paid for; past it, the
|
|
244
|
+
* old layout redrawn is no better on any of them than the redesign, and worse
|
|
245
|
+
* on every other, so a miss here is noted on the page's row, not fallen back
|
|
246
|
+
* on. What it says, holds, links and reads as (facts, invented, held, links,
|
|
247
|
+
* meaning, contrast, a phone's width) stays a fallback.
|
|
248
|
+
*/
|
|
249
|
+
export declare const AI_SITE_IMPORT_IMPROVE_SOFT_CODES: ReadonlySet<string>;
|
|
250
|
+
/** Whether every miss of an answer is one it may be taken with past its last re-ask. */
|
|
251
|
+
export declare function aiSiteImportImproveOnlySoft(violations: readonly AiDoctrineViolation[]): boolean;
|
|
205
252
|
/** Every line a redesign's facts may come from: its page, what the site says of itself, its wave's other pages, its name. */
|
|
206
253
|
export declare function aiSiteImportImproveScope(doc: Pick<AiSiteImportDocument, 'blocks' | 'siteLines' | 'scope' | 'title'>, siteName: string | null): string[];
|
|
207
254
|
/** A scored redesign's misses, each as the re-ask names it: what is red on its ledger and its design lines. */
|
|
@@ -230,4 +277,10 @@ export declare function aiSiteImportImproveCheck<T>(input: {
|
|
|
230
277
|
violations: AiDoctrineViolation[];
|
|
231
278
|
};
|
|
232
279
|
score: (built: T, destinations: readonly string[]) => AiDoctrineViolation[];
|
|
280
|
+
/**
|
|
281
|
+
* The last answer read again once no re-ask is left (AGL-4152): its soft
|
|
282
|
+
* misses (`AI_SITE_IMPORT_IMPROVE_SOFT_CODES`) are noted, not refused.
|
|
283
|
+
* Every other line holds exactly as on the first read.
|
|
284
|
+
*/
|
|
285
|
+
lenient?: boolean;
|
|
233
286
|
}): AiGenerationCheck<AiSiteImportImproved<T>>;
|
|
@@ -42,7 +42,7 @@ import { aiLayoutDesignChoices, aiLayoutGroupVariant } from "../layout-language/
|
|
|
42
42
|
import { AI_LAYOUT_ALIGNS, AI_LAYOUT_BANDS, AI_LAYOUT_MAX_COLS, AI_LAYOUT_STYLES, aiReadLayoutBlock } from "../layout-language/ai-layout-language.js";
|
|
43
43
|
import { AI_ICON_WORDS } from "../runtime/ai-icon-library.js";
|
|
44
44
|
import { aiSiteHomeArc } from "../model/ai-site-home-arcs.js";
|
|
45
|
-
import { siteImportContentKept } from "../model/ai-site-import-fidelity.js";
|
|
45
|
+
import { siteImportContentKept, siteImportContentWords } from "../model/ai-site-import-fidelity.js";
|
|
46
46
|
import { siteImportLedger } from "../model/ai-site-import-ledger.js";
|
|
47
47
|
import { AI_SITE_IMPORT_PAGE_CEILING_CREDITS } from "../model/ai-site-import.js";
|
|
48
48
|
import { estimateAiBilledUsd } from "../providers/catalog.js";
|
|
@@ -214,7 +214,7 @@ const BLOCK_SCHEMA = {
|
|
|
214
214
|
'Block kinds:',
|
|
215
215
|
'- eyebrow: a short label over a heading. heading: the first heading of the first section is the page title; the first heading of any other section is its heading. lede: the larger sentence under a heading. text: a paragraph. note: small print.',
|
|
216
216
|
'- button: text is its label, to where it goes, style primary (filled), secondary (outlined) or quiet. Two in a row read as a pair.',
|
|
217
|
-
'- cards, steps, faq: a group of items, each a title and a text. cards are services, features or reasons; steps are numbered and in order; faq items are a question and its answer. An item may carry an icon, a to, and ref naming a picture of the page, shown on the card.',
|
|
217
|
+
'- cards, steps, faq: a group of items, each a title and a text. cards are services, features or reasons; steps are numbered and in order; faq items are a question and its answer. An item may carry an icon, a to, and ref naming a picture of the page, shown on the card: a picture the ledger lists with lines goes on the card written of those lines, so like cards each show their own.',
|
|
218
218
|
'- list: short lines, title only.',
|
|
219
219
|
'- image: text describes a picture the page should have where none of its own fits; the platform finds one, or leaves it out.',
|
|
220
220
|
'- keep: ref names one thing of the ledger, drawn exactly as the owner has it, so write nothing for it: a picture, form, plan, table, quote, video, contact line, figures, logos, a gallery of photos (drawn as a grid of them), tabs, or a group. Place every thing the ledger marks must, exactly once, wherever it serves the page best, in a column if that helps.',
|
|
@@ -283,17 +283,36 @@ const BLOCK_SCHEMA = {
|
|
|
283
283
|
*-----------------------------------------*/ /** The most characters a page's ledger shows. */ export const AI_SITE_IMPORT_LEDGER_MAX_CHARS = 16000;
|
|
284
284
|
const textOf = (block)=>block && block.kind !== 'image' ? clean(block.text) : '';
|
|
285
285
|
const short = (text, most = 80)=>text.length > most ? `${text.slice(0, most - 1)}…` : text;
|
|
286
|
-
/**
|
|
286
|
+
/**
|
|
287
|
+
* The lines each picture of a page stands with (AGL-4152): the words after it
|
|
288
|
+
* in its section, up to the next picture, as a row of pictured services or a
|
|
289
|
+
* photo over its caption lays them out. What the ledger tells a redesign a
|
|
290
|
+
* picture goes with, and what a card written of those words is given it by.
|
|
291
|
+
*/ export function aiSiteImportPictureCaptions(ledger) {
|
|
292
|
+
const pictures = ledger.items.filter((item)=>item.kind === 'picture' && item.lines[0] !== undefined);
|
|
293
|
+
const out = new Map();
|
|
294
|
+
for (const item of pictures){
|
|
295
|
+
const at = item.lines[0];
|
|
296
|
+
const next = Math.min(...pictures.filter((other)=>other.section === item.section && other.lines[0] > at).map((other)=>other.lines[0]), Number.POSITIVE_INFINITY);
|
|
297
|
+
const lines = ledger.lines.filter((line)=>line.section === item.section && line.line > at && line.line < next && !line.group).slice(0, 2);
|
|
298
|
+
if (lines.length) out.set(item.ref, lines);
|
|
299
|
+
}
|
|
300
|
+
return out;
|
|
301
|
+
}
|
|
302
|
+
/** A ledger item, in a few words: what it is and what it shows. */ function shownItem(item, doc, captions) {
|
|
287
303
|
const must = item.must ? ' must' : '';
|
|
288
304
|
const words = item.lines.map((ref)=>textOf(doc.blocks[ref])).filter(Boolean);
|
|
289
305
|
switch(item.kind){
|
|
290
306
|
case 'picture':
|
|
291
307
|
{
|
|
308
|
+
var _captions_get;
|
|
292
309
|
const block = doc.blocks[item.lines[0]];
|
|
293
310
|
const url = (block == null ? void 0 : block.kind) === 'image' ? block.url : '';
|
|
294
311
|
const photo = doc.photos.find((entry)=>entry.from === url);
|
|
295
312
|
const alt = (block == null ? void 0 : block.kind) === 'image' ? clean(block.alt) : '';
|
|
296
|
-
|
|
313
|
+
// The words it stands with, by their numbers: a card written of them takes it by its ref (AGL-4152).
|
|
314
|
+
const with_ = captions == null ? void 0 : (_captions_get = captions.get(item.ref)) == null ? void 0 : _captions_get.map((line)=>`[${line.line}]`).join(', ');
|
|
315
|
+
return `${item.ref}${must} (${(photo == null ? void 0 : photo.width) && photo.height ? `${photo.width}×${photo.height}, ` : ''}"${short(alt, 60)}"${with_ ? `, with ${with_}` : ''})`;
|
|
297
316
|
}
|
|
298
317
|
case 'form':
|
|
299
318
|
return `${item.ref}${must} (a form)`;
|
|
@@ -358,12 +377,13 @@ const short = (text, most = 80)=>text.length > most ? `${text.slice(0, most - 1)
|
|
|
358
377
|
});
|
|
359
378
|
// A long page shows each group by its titles alone, kept whole: what is around them is written (AGL-4152).
|
|
360
379
|
const lines = ledger.folded ? ledger.lines.filter((line)=>!line.group) : ledger.lines;
|
|
380
|
+
const captions = aiSiteImportPictureCaptions(ledger);
|
|
361
381
|
return [
|
|
362
382
|
...ledger.folded ? [
|
|
363
383
|
'This page is long: its groups are folded, each shown by its titles and kept whole with keep.'
|
|
364
384
|
] : [],
|
|
365
385
|
'Things to place with keep, each once; "must" may not be left out:',
|
|
366
|
-
...ledger.items.length ? ledger.items.map((item)=>shownItem(item, doc)) : [
|
|
386
|
+
...ledger.items.length ? ledger.items.map((item)=>shownItem(item, doc, captions)) : [
|
|
367
387
|
'(none)'
|
|
368
388
|
],
|
|
369
389
|
'',
|
|
@@ -432,17 +452,20 @@ const short = (text, most = 80)=>text.length > most ? `${text.slice(0, most - 1)
|
|
|
432
452
|
* What the page is for, and what it needs
|
|
433
453
|
*-----------------------------------------*/ /**
|
|
434
454
|
* How many new sections a page of each role is asked for (AGL-4152): a home
|
|
435
|
-
* or a main service page two, a contact page none, its form framed instead
|
|
455
|
+
* or a main service page two, a contact page none, its form framed instead,
|
|
456
|
+
* and a gallery none: its pictures are what it is for, and a section added
|
|
457
|
+
* to a page of photos only stands between a visitor and them.
|
|
436
458
|
*/ export const AI_SITE_IMPORT_NEW_SECTIONS = {
|
|
437
459
|
home: 2,
|
|
438
460
|
service: 2,
|
|
439
461
|
about: 1,
|
|
440
|
-
gallery:
|
|
462
|
+
gallery: 0,
|
|
441
463
|
pricing: 1,
|
|
442
464
|
other: 1,
|
|
443
465
|
contact: 0,
|
|
444
466
|
faq: 0
|
|
445
467
|
};
|
|
468
|
+
/** The fewest content words an old section says for a new one to be its rework (AGL-4152): fewer is a label, which any section may echo. */ export const AI_SITE_IMPORT_REWORK_LEAST_WORDS = 4;
|
|
446
469
|
/** The most sections a redesigned page runs to: a page the source already fills has no room for more. */ export const AI_SITE_IMPORT_IMPROVE_MOST_SECTIONS = 10;
|
|
447
470
|
/** What a page is for, as its plan says, else from its address and what it holds. */ export function aiSiteImportPageRoleOf(doc, slug) {
|
|
448
471
|
if (doc.role) return doc.role;
|
|
@@ -496,7 +519,9 @@ const short = (text, most = 80)=>text.length > most ? `${text.slice(0, most - 1)
|
|
|
496
519
|
* its own, and the rework of no section of the old page. Each section of the
|
|
497
520
|
* old page past its opening is reworked by the one section that says most
|
|
498
521
|
* of it; another section drawing on its words, such as a why-us of the
|
|
499
|
-
* opening's facts, is new.
|
|
522
|
+
* opening's facts, is new. An old section of a few words, a heading over a
|
|
523
|
+
* band or a label over a kept group, reworks nothing: any new section that
|
|
524
|
+
* happens to say its two or three words would otherwise read as its rework.
|
|
500
525
|
*/ export function aiSiteImportImproveNewSections(answer, ledger) {
|
|
501
526
|
var _sources_get;
|
|
502
527
|
const kinds = new Map(ledger.items.map((item)=>[
|
|
@@ -523,6 +548,7 @@ const short = (text, most = 80)=>text.length > most ? `${text.slice(0, most - 1)
|
|
|
523
548
|
for (const [at, lines] of sources){
|
|
524
549
|
if (at === 0) continue;
|
|
525
550
|
const text = lines.join(' ');
|
|
551
|
+
if (siteImportContentWords(text) < AI_SITE_IMPORT_REWORK_LEAST_WORDS) continue;
|
|
526
552
|
let best = -1;
|
|
527
553
|
let most = 0.5;
|
|
528
554
|
said.forEach((words, index)=>{
|
|
@@ -673,9 +699,21 @@ const short = (text, most = 80)=>text.length > most ? `${text.slice(0, most - 1)
|
|
|
673
699
|
}
|
|
674
700
|
/*------------------------------------------
|
|
675
701
|
* The answer in the compiler's language
|
|
676
|
-
*-----------------------------------------*/ /** The
|
|
677
|
-
|
|
702
|
+
*-----------------------------------------*/ /** The least width over height of an opening photo a redesign lays its words over (AGL-4152): a landscape, not a square or a portrait. */ export const AI_SITE_IMPORT_COVER_LEAST_RATIO = 1.3;
|
|
703
|
+
/** The heroes that box their photo under the words: a masthead's and an editorial's. */ const BOXED_HEROES = new Set([
|
|
704
|
+
'column',
|
|
705
|
+
'editorial'
|
|
706
|
+
]);
|
|
707
|
+
/**
|
|
708
|
+
* The site's hero as a page brought in draws it: a collage or a portrait holds
|
|
709
|
+
* what a page brought in does not. A redesign whose opening holds the page's
|
|
710
|
+
* own landscape photo lays its words over it (AGL-4152): a hero that boxes a
|
|
711
|
+
* wide photo under centered words reads as a picture pasted below a heading,
|
|
712
|
+
* the way an old page looks, never as a brand's opening.
|
|
713
|
+
*/ export function aiSiteImportImproveHero(design, plan, opening) {
|
|
714
|
+
var _ref, _ref1;
|
|
678
715
|
const chosen = (_ref = plan == null ? void 0 : plan.design.hero) != null ? _ref : aiLayoutDesignChoices(design).hero;
|
|
716
|
+
if (BOXED_HEROES.has(chosen) && ((_ref1 = opening == null ? void 0 : opening.ratio) != null ? _ref1 : 0) >= AI_SITE_IMPORT_COVER_LEAST_RATIO) return 'cover';
|
|
679
717
|
return chosen === 'collage' || chosen === 'portrait' ? 'split' : chosen;
|
|
680
718
|
}
|
|
681
719
|
/** How many of a group's items sit across: planned for how much each says. */ export function aiSiteImportImproveColumns(items) {
|
|
@@ -698,6 +736,59 @@ const WORD_KINDS = new Set([
|
|
|
698
736
|
wide: '16 / 9',
|
|
699
737
|
column: '4 / 3'
|
|
700
738
|
};
|
|
739
|
+
/** The least share of a picture's own words a card says for the card to take that picture (AGL-4152). */ const CARD_PICTURE_KEPT = 0.5;
|
|
740
|
+
/**
|
|
741
|
+
* The source's own pictures each set of written cards takes (AGL-4152), by
|
|
742
|
+
* block: where an answer wrote like services as cards and gave none of them a
|
|
743
|
+
* picture, while the page's photos of those same services sit unplaced, each
|
|
744
|
+
* card takes the photo whose words it says. Every card must find one, or the
|
|
745
|
+
* set takes none: a grid of cards half of which show a photo reads as broken.
|
|
746
|
+
* Where no card says a photo's words but the one section's unplaced photos
|
|
747
|
+
* number exactly the cards, they are taken in order, as the source laid them.
|
|
748
|
+
*/ export function aiSiteImportCardPictures(answer, ledger) {
|
|
749
|
+
const placed = new Set(aiSiteImportImprovedPlaced(answer, ledger));
|
|
750
|
+
const captions = aiSiteImportPictureCaptions(ledger);
|
|
751
|
+
const taken = new Set();
|
|
752
|
+
const out = new Map();
|
|
753
|
+
for (const section of answer){
|
|
754
|
+
for (const block of section.blocks){
|
|
755
|
+
var _block_items;
|
|
756
|
+
if (block.kind !== 'cards') continue;
|
|
757
|
+
const items = (_block_items = block.items) != null ? _block_items : [];
|
|
758
|
+
if (items.length < 2 || items.some((item)=>item.ref)) continue;
|
|
759
|
+
const pool = ledger.items.filter((item)=>item.kind === 'picture' && !placed.has(item.ref) && !taken.has(item.ref));
|
|
760
|
+
if (pool.length < items.length) continue;
|
|
761
|
+
const said = (ref)=>{
|
|
762
|
+
var _captions_get;
|
|
763
|
+
return ((_captions_get = captions.get(ref)) != null ? _captions_get : []).map((line)=>line.text);
|
|
764
|
+
};
|
|
765
|
+
const chosen = [];
|
|
766
|
+
for (const item of items){
|
|
767
|
+
const words = `${item.title} ${item.text}`;
|
|
768
|
+
let best = null;
|
|
769
|
+
let most = CARD_PICTURE_KEPT;
|
|
770
|
+
for (const picture of pool){
|
|
771
|
+
if (chosen.includes(picture.ref)) continue;
|
|
772
|
+
const lines = said(picture.ref);
|
|
773
|
+
if (!lines.length) continue;
|
|
774
|
+
const kept = Math.max(siteImportContentKept(lines[0], words), siteImportContentKept(lines.join(' '), words));
|
|
775
|
+
if (kept >= most) {
|
|
776
|
+
most = kept;
|
|
777
|
+
best = picture.ref;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
if (!best) break;
|
|
781
|
+
chosen.push(best);
|
|
782
|
+
}
|
|
783
|
+
const sections = new Set(pool.map((picture)=>picture.section));
|
|
784
|
+
const refs = chosen.length === items.length ? chosen : !chosen.length && sections.size === 1 && pool.length === items.length ? pool.map((picture)=>picture.ref) : null;
|
|
785
|
+
if (!refs) continue;
|
|
786
|
+
for (const ref of refs)taken.add(ref);
|
|
787
|
+
out.set(block, refs);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return out;
|
|
791
|
+
}
|
|
701
792
|
/** The sections' names: each heading's words, as a label, told apart. */ function sectionNames(sections, title) {
|
|
702
793
|
const taken = new Set();
|
|
703
794
|
return sections.map((section, index)=>{
|
|
@@ -779,7 +870,11 @@ const WORD_KINDS = new Set([
|
|
|
779
870
|
allowed: false
|
|
780
871
|
}).map((block)=>_extends({}, block, placed, across(block, col !== undefined)));
|
|
781
872
|
};
|
|
873
|
+
// The source's pictures a written set of cards stands for, where the answer gave them none (AGL-4152).
|
|
874
|
+
const carded = aiSiteImportCardPictures(answer, ledger);
|
|
782
875
|
const sections = answer.map((section, index)=>{
|
|
876
|
+
var _pictures__picture;
|
|
877
|
+
var _pictures_;
|
|
783
878
|
scope.at = `sections[${index}]`;
|
|
784
879
|
const words = section.blocks.flatMap((block)=>{
|
|
785
880
|
var _block_text;
|
|
@@ -828,9 +923,11 @@ const WORD_KINDS = new Set([
|
|
|
828
923
|
];
|
|
829
924
|
}
|
|
830
925
|
const groupItems = ((_block_items = block.items) != null ? _block_items : []).map((item, at)=>{
|
|
926
|
+
var _carded_get;
|
|
831
927
|
say(item.title);
|
|
832
928
|
say(item.text);
|
|
833
|
-
const
|
|
929
|
+
const given = item.ref || ((_carded_get = carded.get(block)) == null ? void 0 : _carded_get[at]);
|
|
930
|
+
const picture = given ? pictureOf(given, '4 / 3') : null;
|
|
834
931
|
const to = resolve(item.to);
|
|
835
932
|
const { ref: _ref, to: _to } = item, rest = _object_without_properties_loose(item, [
|
|
836
933
|
"ref",
|
|
@@ -870,7 +967,8 @@ const WORD_KINDS = new Set([
|
|
|
870
967
|
});
|
|
871
968
|
const pictures = blocks.filter((block)=>block.kind === 'image' || block.kind === 'video');
|
|
872
969
|
const opens = index === 0 && pictures.length === 1 && blocks.every((block)=>block.kind === 'image' || block.kind === 'video' || WORD_KINDS.has(block.kind));
|
|
873
|
-
const
|
|
970
|
+
const opening = ((_pictures_ = pictures[0]) == null ? void 0 : _pictures_.kind) === 'image' ? (_pictures__picture = pictures[0].picture) != null ? _pictures__picture : null : null;
|
|
971
|
+
const hero = opens ? aiSiteImportImproveHero(design, input.plan, opening) : null;
|
|
874
972
|
const band = section.band === 'brand' && deepened ? 'dark' : section.band;
|
|
875
973
|
return _extends({}, band ? {
|
|
876
974
|
band
|
|
@@ -902,7 +1000,12 @@ const WORD_KINDS = new Set([
|
|
|
902
1000
|
items: group.items.length
|
|
903
1001
|
} : {});
|
|
904
1002
|
});
|
|
905
|
-
const placed = new Set(
|
|
1003
|
+
const placed = new Set([
|
|
1004
|
+
...aiSiteImportImprovedPlaced(answer, ledger),
|
|
1005
|
+
...[
|
|
1006
|
+
...carded.values()
|
|
1007
|
+
].flat()
|
|
1008
|
+
]);
|
|
906
1009
|
const allPictures = ledger.items.filter((item)=>item.kind === 'picture');
|
|
907
1010
|
const unplaced = allPictures.filter((item)=>!placed.has(item.ref)).flatMap((item)=>{
|
|
908
1011
|
const block = doc.blocks[item.lines[0]];
|
|
@@ -1009,6 +1112,26 @@ const plus = (a, b)=>({
|
|
|
1009
1112
|
} : {}));
|
|
1010
1113
|
return room >= Math.ceil(input.lastOutput * AI_SITE_IMPORT_REASK_ROOM) ? room : 0;
|
|
1011
1114
|
}
|
|
1115
|
+
/**
|
|
1116
|
+
* What a redesign may still miss when no re-ask is left and be taken all the
|
|
1117
|
+
* same (AGL-4152): how it is planned and drawn, never what it says or holds.
|
|
1118
|
+
* Each is asked for in the one re-ask where it can be paid for; past it, the
|
|
1119
|
+
* old layout redrawn is no better on any of them than the redesign, and worse
|
|
1120
|
+
* on every other, so a miss here is noted on the page's row, not fallen back
|
|
1121
|
+
* on. What it says, holds, links and reads as (facts, invented, held, links,
|
|
1122
|
+
* meaning, contrast, a phone's width) stays a fallback.
|
|
1123
|
+
*/ export const AI_SITE_IMPORT_IMPROVE_SOFT_CODES = new Set([
|
|
1124
|
+
'improve-new-sections',
|
|
1125
|
+
'improve-opening',
|
|
1126
|
+
'improve-shapes',
|
|
1127
|
+
'improve-cta',
|
|
1128
|
+
'improve-rhythm',
|
|
1129
|
+
'improve-columns',
|
|
1130
|
+
'improve-framing'
|
|
1131
|
+
]);
|
|
1132
|
+
/** Whether every miss of an answer is one it may be taken with past its last re-ask. */ export function aiSiteImportImproveOnlySoft(violations) {
|
|
1133
|
+
return violations.length > 0 && violations.every((violation)=>AI_SITE_IMPORT_IMPROVE_SOFT_CODES.has(violation.code));
|
|
1134
|
+
}
|
|
1012
1135
|
/** Every line a redesign's facts may come from: its page, what the site says of itself, its wave's other pages, its name. */ export function aiSiteImportImproveScope(doc, siteName) {
|
|
1013
1136
|
var _doc_siteLines, _doc_scope;
|
|
1014
1137
|
const own = doc.blocks.flatMap((block)=>block.kind === 'image' ? block.alt ? [
|
|
@@ -1104,7 +1227,8 @@ const plus = (a, b)=>({
|
|
|
1104
1227
|
ledger: input.ledger,
|
|
1105
1228
|
needs: input.needs
|
|
1106
1229
|
}) : [];
|
|
1107
|
-
|
|
1230
|
+
const missed = input.lenient ? planned.map((violation)=>violation.code) : [];
|
|
1231
|
+
if (honesty.length || planned.length && !input.lenient) return {
|
|
1108
1232
|
value: null,
|
|
1109
1233
|
violations: [
|
|
1110
1234
|
...honesty,
|
|
@@ -1131,18 +1255,24 @@ const plus = (a, b)=>({
|
|
|
1131
1255
|
to
|
|
1132
1256
|
] : [];
|
|
1133
1257
|
});
|
|
1134
|
-
const
|
|
1258
|
+
const scored = input.score(built.value, [
|
|
1135
1259
|
...new Set(wanted)
|
|
1136
1260
|
]);
|
|
1137
|
-
|
|
1261
|
+
const refused = input.lenient ? scored.filter((violation)=>!AI_SITE_IMPORT_IMPROVE_SOFT_CODES.has(violation.code)) : scored;
|
|
1262
|
+
if (refused.length) return {
|
|
1138
1263
|
value: null,
|
|
1139
|
-
violations:
|
|
1264
|
+
violations: refused
|
|
1140
1265
|
};
|
|
1266
|
+
missed.push(...scored.map((violation)=>violation.code));
|
|
1141
1267
|
return {
|
|
1142
|
-
value: {
|
|
1268
|
+
value: _extends({
|
|
1143
1269
|
built: built.value,
|
|
1144
1270
|
page
|
|
1145
|
-
},
|
|
1271
|
+
}, missed.length ? {
|
|
1272
|
+
missed: [
|
|
1273
|
+
...new Set(missed)
|
|
1274
|
+
]
|
|
1275
|
+
} : {}),
|
|
1146
1276
|
violations: []
|
|
1147
1277
|
};
|
|
1148
1278
|
};
|