@vectoriox/iox-ui 5.203.0 → 5.205.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.
- package/actions-core/index.d.ts +8 -1
- package/design-core/index.d.ts +70 -2
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +8 -1
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +131 -11
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +5294 -267
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +524 -112
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +2308 -6
- package/index.d.ts +159 -13
- package/package.json +1 -1
- package/src/actions-core/element-actions.ts +9 -0
- package/src/design-core/contrast-audit.ts +93 -11
- package/src/design-core/flavor-spec.generated.ts +19 -0
- package/src/design-core/image-alt.ts +27 -0
- package/src/design-core/node-links.ts +12 -0
- package/src/design-core/public-api.ts +1 -0
- package/src/generation-core/ai-run.ts +31 -0
- package/src/generation-core/audit-site.ts +17 -3
- package/src/generation-core/baseline-roles.ts +10 -6
- package/src/generation-core/check-free.ts +12 -2
- package/src/generation-core/check-layout.ts +3 -2
- package/src/generation-core/critic-calibration.ts +178 -0
- package/src/generation-core/critic-prompt.ts +174 -0
- package/src/generation-core/critic-rubric.generated.ts +24 -0
- package/src/generation-core/critic-sheet.ts +270 -0
- package/src/generation-core/critic.ts +189 -0
- package/src/generation-core/design-doc-index.ts +58 -0
- package/src/generation-core/design-motion.ts +247 -0
- package/src/generation-core/design-ops-check.ts +370 -0
- package/src/generation-core/design-ops-of.ts +200 -0
- package/src/generation-core/design-ops.model.ts +239 -0
- package/src/generation-core/design-ops.schema.ts +122 -0
- package/src/generation-core/design-ops.ts +361 -0
- package/src/generation-core/design-recipes.ts +58 -0
- package/src/generation-core/designer-brief.ts +82 -0
- package/src/generation-core/designer-direction.ts +248 -0
- package/src/generation-core/designer-estimate.ts +171 -0
- package/src/generation-core/designer-lessons.generated.ts +653 -0
- package/src/generation-core/designer-lessons.ts +153 -0
- package/src/generation-core/designer-stop.ts +94 -0
- package/src/generation-core/footer-mix.ts +3 -1
- package/src/generation-core/node-baselines.generated.ts +953 -10
- package/src/generation-core/public-api.ts +20 -0
- package/src/generation-core/site-spec.generated.ts +73 -11
- package/src/generation-core/social-links.ts +195 -2
- package/src/generation-core/structure-fingerprint.ts +565 -0
- package/src/generation-core/templates.ts +39 -3
- package/styles/iox-design.css +26 -1
- package/styles/iox-forms.css +22 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { jsonClosedObject, jsonListOf, JsonSchema, jsonText } from './json-schema';
|
|
2
|
+
import { isPlainObject, PathIssue } from './shape-check';
|
|
3
|
+
import {
|
|
4
|
+
conceptsDistinct, designFreedomIssues, FreedomIssue, NamedStructure, SectionShape, StructureFingerprint, StructureSignature,
|
|
5
|
+
} from './structure-fingerprint';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* THE AI DESIGNER'S DIRECTION (ai-designer-plan §2a, §2a′, AD-D17, AD-D19, AD-D20, R-H24): two strict answers, both before
|
|
9
|
+
* anything renders.
|
|
10
|
+
* - THE CONCEPTS (`designerConceptsSchema`): three directions for the site, each a name, one sentence, a signature move and
|
|
11
|
+
* a PLANNED structure (the Home's sections as `SectionShape`s) — so `conceptsDistinct` and `designFreedomIssues` judge
|
|
12
|
+
* them before a sketch is paid for — and the designer's own pick with its reason ("You decide", board Q3).
|
|
13
|
+
* - THE ART DIRECTION (`designerDirectionSchema`): the ten lines of hotel HARNESS §2 for the chosen concept — the one sentence,
|
|
14
|
+
* the signature, the grounds in order, the four type roles, the opening, the header, the named parts, the motion
|
|
15
|
+
* vocabulary, the picture families with their mood words, and what NOT to copy. Stored with the build, shown to the
|
|
16
|
+
* owner as "the direction". (Named `DesignerDirection`, not "art direction": `art-direction.ts` is the PICTURE world —
|
|
17
|
+
* the preamble every generated picture opens with — and stays so; line 9's mood words feed the stock search beside it.)
|
|
18
|
+
* Each schema is one strict request inside `STRICT_SCHEMA_BUDGET`; the checks are this file's, never the model's. Pure.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** Three concepts (§2a′ point 4). */
|
|
22
|
+
export const DESIGNER_CONCEPTS = 3;
|
|
23
|
+
/** A planned Home: this many sections, at least and at most (the references' Homes run 5–16). */
|
|
24
|
+
export const CONCEPT_SECTIONS = { min: 4, max: 12 } as const;
|
|
25
|
+
/** The art direction's named parts (§2a line 7) and picture families (line 9). */
|
|
26
|
+
export const DIRECTION_NAMED_PARTS = { min: 2, max: 3 } as const;
|
|
27
|
+
export const DIRECTION_PICTURE_FAMILIES = { min: 2, max: 6 } as const;
|
|
28
|
+
|
|
29
|
+
export const DESIGNER_CONCEPTS_OUTPUT_NAME = 'concepts';
|
|
30
|
+
export const DESIGNER_DIRECTION_OUTPUT_NAME = 'design_direction';
|
|
31
|
+
|
|
32
|
+
// ── The concepts ────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
export interface DesignerConcept {
|
|
35
|
+
name: string;
|
|
36
|
+
/** One sentence: what the site feels like. */
|
|
37
|
+
sentence: string;
|
|
38
|
+
/** The one move people remember. */
|
|
39
|
+
signature: string;
|
|
40
|
+
/** The Home's sections, in order, as shapes. */
|
|
41
|
+
structure: SectionShape[];
|
|
42
|
+
}
|
|
43
|
+
export interface DesignerConcepts {
|
|
44
|
+
concepts: DesignerConcept[];
|
|
45
|
+
/** "You decide": the designer's own pick (an index into `concepts`) and why, in one line. */
|
|
46
|
+
pick: { concept: number; reason: string };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function designerConceptsSchema(): JsonSchema {
|
|
50
|
+
const concept = jsonClosedObject({
|
|
51
|
+
name: { ...jsonText(), description: 'Two or three words the owner can call it by.' },
|
|
52
|
+
sentence: { ...jsonText(), description: 'One sentence: what the site feels like, in the owner\'s words.' },
|
|
53
|
+
signature: { ...jsonText(), description: 'The one move people remember (a held stage, a sideways walk, words lit by the scroll…).' },
|
|
54
|
+
structure: {
|
|
55
|
+
...jsonListOf({ type: 'string', enum: Object.values(SectionShape) }),
|
|
56
|
+
description: `The Home's sections in order, ${CONCEPT_SECTIONS.min}–${CONCEPT_SECTIONS.max}, each as its shape — the three concepts must differ in structure, not only in styling.`,
|
|
57
|
+
},
|
|
58
|
+
}, ['name', 'sentence', 'signature', 'structure'], 'One direction for the site.');
|
|
59
|
+
return jsonClosedObject({
|
|
60
|
+
concepts: { ...jsonListOf(concept), description: `Exactly ${DESIGNER_CONCEPTS} directions, each with a different structure and a different signature move.` },
|
|
61
|
+
pick: jsonClosedObject({
|
|
62
|
+
concept: { type: 'number', description: `The direction you would choose: 0–${DESIGNER_CONCEPTS - 1}.` },
|
|
63
|
+
reason: { ...jsonText(), description: 'Why, in one line the owner reads.' },
|
|
64
|
+
}, ['concept', 'reason'], 'Your own pick, for an owner who answers "You decide".'),
|
|
65
|
+
}, ['concepts', 'pick'], 'Three directions for the site and your pick.');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** What a shape carries into a planned structure: whether it holds a picture, and the signature part it is. */
|
|
69
|
+
const PICTURE_SHAPES: ReadonlySet<SectionShape> = new Set([SectionShape.Media, SectionShape.PhotoGround, SectionShape.Split, SectionShape.Grid]);
|
|
70
|
+
const SHAPE_SIGNATURE: Readonly<Partial<Record<SectionShape, StructureSignature>>> = {
|
|
71
|
+
[SectionShape.Held]: StructureSignature.Held,
|
|
72
|
+
[SectionShape.Sideways]: StructureSignature.Sideways,
|
|
73
|
+
[SectionShape.Marquee]: StructureSignature.Marquee,
|
|
74
|
+
[SectionShape.Form]: StructureSignature.Form,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** A planned structure (a concept's shapes) as a fingerprint, read as a reading's words are (the media share is the
|
|
78
|
+
* share of picture shapes) — comparable with built pages, stored builds and references (structure-fingerprint). */
|
|
79
|
+
export function plannedStructure(shapes: ReadonlyArray<SectionShape>): StructureFingerprint {
|
|
80
|
+
const signatures = [...new Set(shapes.map(s => SHAPE_SIGNATURE[s]).filter((s): s is StructureSignature => !!s))].sort();
|
|
81
|
+
return {
|
|
82
|
+
opening: shapes[0] ?? SectionShape.Composition,
|
|
83
|
+
shapes: [...shapes],
|
|
84
|
+
media: shapes.length ? Math.round((shapes.filter(s => PICTURE_SHAPES.has(s)).length / shapes.length) * 1000) / 1000 : 0,
|
|
85
|
+
signatures,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export enum DirectionIssueCode {
|
|
90
|
+
Shape = 'shape',
|
|
91
|
+
/** Not three concepts, a section count out of range, an unknown shape. */
|
|
92
|
+
Count = 'count',
|
|
93
|
+
/** Two concepts with one name or one signature move. */
|
|
94
|
+
Same = 'same',
|
|
95
|
+
/** R-H24: two concepts on one structure (`conceptsDistinct`). */
|
|
96
|
+
NotDistinct = 'not-distinct',
|
|
97
|
+
/** AD-D19: a concept that copies the reference or repeats the kind's recent builds (`designFreedomIssues`). */
|
|
98
|
+
Freedom = 'freedom',
|
|
99
|
+
/** The pick is not one of the concepts, or has no reason. */
|
|
100
|
+
Pick = 'pick',
|
|
101
|
+
}
|
|
102
|
+
export type DirectionIssue = PathIssue<DirectionIssueCode> & { freedom?: FreedomIssue };
|
|
103
|
+
|
|
104
|
+
const SHAPES: ReadonlySet<string> = new Set(Object.values(SectionShape));
|
|
105
|
+
const filled = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0;
|
|
106
|
+
const key = (s: string) => s.trim().toLowerCase();
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The concepts, judged before a sketch is paid for: three, each a name, a sentence, a signature and a planned Home of
|
|
110
|
+
* 4–12 known shapes; no two with one name or one signature; pairwise distinct in structure (R-H24); none a copy of the
|
|
111
|
+
* reference nor a repeat of the kind's recent builds (AD-D19); the pick one of them, with a reason.
|
|
112
|
+
*/
|
|
113
|
+
export function conceptsIssues(answer: unknown, context: { reference?: NamedStructure; recent?: ReadonlyArray<NamedStructure> } = {}): DirectionIssue[] {
|
|
114
|
+
const out: DirectionIssue[] = [];
|
|
115
|
+
const say = (code: DirectionIssueCode, path: string, message: string, freedom?: FreedomIssue) => out.push({ code, path, message, ...(freedom ? { freedom } : {}) });
|
|
116
|
+
if (!isPlainObject(answer) || !Array.isArray(answer['concepts']) || !isPlainObject(answer['pick'])) {
|
|
117
|
+
say(DirectionIssueCode.Shape, '', 'the concepts are { concepts, pick }');
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
const concepts = answer['concepts'] as unknown[];
|
|
121
|
+
if (concepts.length !== DESIGNER_CONCEPTS) say(DirectionIssueCode.Count, 'concepts', `exactly ${DESIGNER_CONCEPTS} concepts, not ${concepts.length}`);
|
|
122
|
+
const valid: Array<{ at: number; concept: DesignerConcept }> = [];
|
|
123
|
+
concepts.forEach((c, at) => {
|
|
124
|
+
const path = `concepts[${at}]`;
|
|
125
|
+
if (!isPlainObject(c) || !filled(c['name']) || !filled(c['sentence']) || !filled(c['signature']) || !Array.isArray(c['structure'])) {
|
|
126
|
+
say(DirectionIssueCode.Shape, path, 'a concept is { name, sentence, signature, structure }');
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const structure = c['structure'] as unknown[];
|
|
130
|
+
const unknown = structure.filter(s => typeof s !== 'string' || !SHAPES.has(s));
|
|
131
|
+
if (unknown.length) { say(DirectionIssueCode.Count, `${path}.structure`, `unknown shapes: ${unknown.join(', ')}`); return; }
|
|
132
|
+
if (structure.length < CONCEPT_SECTIONS.min || structure.length > CONCEPT_SECTIONS.max) {
|
|
133
|
+
say(DirectionIssueCode.Count, `${path}.structure`, `${CONCEPT_SECTIONS.min}–${CONCEPT_SECTIONS.max} sections, not ${structure.length}`);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
valid.push({ at, concept: c as unknown as DesignerConcept });
|
|
137
|
+
});
|
|
138
|
+
for (const field of ['name', 'signature'] as const) {
|
|
139
|
+
const seen = new Map<string, number>();
|
|
140
|
+
for (const { at, concept } of valid) {
|
|
141
|
+
const was = seen.get(key(concept[field]));
|
|
142
|
+
if (was !== undefined) say(DirectionIssueCode.Same, `concepts[${at}].${field}`, `the same ${field} as concept ${was}`);
|
|
143
|
+
else seen.set(key(concept[field]), at);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (valid.length === concepts.length && valid.length > 1) {
|
|
147
|
+
const distinct = conceptsDistinct(valid.map(v => plannedStructure(v.concept.structure)));
|
|
148
|
+
if (!distinct.distinct && distinct.closest) {
|
|
149
|
+
say(DirectionIssueCode.NotDistinct, `concepts[${distinct.closest.b}].structure`, `concepts ${distinct.closest.a} and ${distinct.closest.b} are one structure (distance ${distinct.closest.distance}) — change the order and the shapes of the sections`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
for (const { at, concept } of valid) {
|
|
153
|
+
for (const issue of designFreedomIssues(plannedStructure(concept.structure), context)) say(DirectionIssueCode.Freedom, `concepts[${at}].structure`, issue.message, issue);
|
|
154
|
+
}
|
|
155
|
+
const pick = answer['pick'];
|
|
156
|
+
if (typeof pick['concept'] !== 'number' || !Number.isInteger(pick['concept']) || pick['concept'] < 0 || pick['concept'] >= concepts.length) {
|
|
157
|
+
say(DirectionIssueCode.Pick, 'pick.concept', `one of the concepts: 0–${concepts.length - 1}`);
|
|
158
|
+
}
|
|
159
|
+
if (!filled(pick['reason'])) say(DirectionIssueCode.Pick, 'pick.reason', 'one line: why this one');
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ── The art direction (the ten lines) ───────────────────────────────────────────────────────────────────────────────
|
|
164
|
+
|
|
165
|
+
/** The four type roles (§2a line 4). */
|
|
166
|
+
export enum DirectionTypeRole {
|
|
167
|
+
Display = 'display',
|
|
168
|
+
Headings = 'headings',
|
|
169
|
+
Body = 'body',
|
|
170
|
+
Labels = 'labels',
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface DesignerDirection {
|
|
174
|
+
/** 1. Why the owner picked the references — the feeling, in one sentence. */
|
|
175
|
+
sentence: string;
|
|
176
|
+
/** 2. The one move people remember. */
|
|
177
|
+
signature: string;
|
|
178
|
+
/** 3. The grounds of the Home's sections, in order (`cream`, `dark`, `photo`…). */
|
|
179
|
+
grounds: string[];
|
|
180
|
+
/** 4. The four type roles: the face, the size, where it is used. */
|
|
181
|
+
type: Record<DirectionTypeRole, string>;
|
|
182
|
+
/** 5. What fills the first screen, where the words sit, what moves on load. */
|
|
183
|
+
opening: string;
|
|
184
|
+
/** 6. The header at rest, scrolled, and on the phone. */
|
|
185
|
+
header: { rest: string; scrolled: string; phone: string };
|
|
186
|
+
/** 7. The 2–3 parts the owner named, built first. */
|
|
187
|
+
parts: string[];
|
|
188
|
+
/** 8. The ONE curve, the entrance, the scroll moment, the hover. */
|
|
189
|
+
motion: { curve: string; entrance: string; scroll: string; hover: string };
|
|
190
|
+
/** 9. Picture families and their mood words (they drive the stock search). */
|
|
191
|
+
pictures: Array<{ family: string; mood: string }>;
|
|
192
|
+
/** 10. What NOT to copy from the references: their facts, their places — this business's own instead. */
|
|
193
|
+
notToCopy: string;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function designerDirectionSchema(): JsonSchema {
|
|
197
|
+
const line = (description: string): JsonSchema => ({ ...jsonText(), description });
|
|
198
|
+
return jsonClosedObject({
|
|
199
|
+
sentence: line('1. Why the owner picked the references — the feeling, in one sentence.'),
|
|
200
|
+
signature: line('2. The one move people remember.'),
|
|
201
|
+
grounds: { ...jsonListOf(jsonText()), description: '3. The ground of each Home section, in order (cream, dark, photo…); count the dark ones.' },
|
|
202
|
+
type: jsonClosedObject(Object.fromEntries(Object.values(DirectionTypeRole).map(r => [r, line(`The ${r} face, its size and where it is used.`)])), Object.values(DirectionTypeRole), '4. The four type roles.'),
|
|
203
|
+
opening: line('5. What fills the first screen, where the words sit, what moves on load.'),
|
|
204
|
+
header: jsonClosedObject({ rest: jsonText(), scrolled: jsonText(), phone: jsonText() }, ['rest', 'scrolled', 'phone'], '6. The header at rest, scrolled, and on the phone.'),
|
|
205
|
+
parts: { ...jsonListOf(jsonText()), description: `7. The ${DIRECTION_NAMED_PARTS.min}–${DIRECTION_NAMED_PARTS.max} parts the owner named — built first, they carry the score.` },
|
|
206
|
+
motion: jsonClosedObject({ curve: jsonText(), entrance: jsonText(), scroll: jsonText(), hover: jsonText() }, ['curve', 'entrance', 'scroll', 'hover'], '8. The ONE curve, the entrance, the scroll moment, the hover (transform and opacity only).'),
|
|
207
|
+
pictures: { ...jsonListOf(jsonClosedObject({ family: jsonText(), mood: jsonText() }, ['family', 'mood'])), description: `9. ${DIRECTION_PICTURE_FAMILIES.min}–${DIRECTION_PICTURE_FAMILIES.max} picture families, each with its mood words.` },
|
|
208
|
+
notToCopy: line('10. What NOT to copy: the references\' facts and places — this business\'s own instead.'),
|
|
209
|
+
}, ['sentence', 'signature', 'grounds', 'type', 'opening', 'header', 'parts', 'motion', 'pictures', 'notToCopy'], 'The art direction: the ten lines.');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export enum DesignerDirectionIssueCode {
|
|
213
|
+
Shape = 'shape',
|
|
214
|
+
Empty = 'empty',
|
|
215
|
+
Count = 'count',
|
|
216
|
+
/** A motion line that animates something other than transform / opacity (Emil, §2f). */
|
|
217
|
+
Motion = 'motion',
|
|
218
|
+
}
|
|
219
|
+
export type DesignerDirectionIssue = PathIssue<DesignerDirectionIssueCode>;
|
|
220
|
+
/** Emil (§2f): motion moves transform, opacity (and clip-path / a filter) — never a size, a position or a colour. */
|
|
221
|
+
const MOTION_FORBIDDEN = /\b(width|height|top|left|right|bottom|margin|padding|background-colou?r|colou?r change|transition:\s*all)\b/i;
|
|
222
|
+
|
|
223
|
+
/** The ten lines, judged: every line filled, the counts held, the motion on transform and opacity only. */
|
|
224
|
+
export function designerDirectionIssues(answer: unknown): DesignerDirectionIssue[] {
|
|
225
|
+
const out: DesignerDirectionIssue[] = [];
|
|
226
|
+
const say = (code: DesignerDirectionIssueCode, path: string, message: string) => out.push({ code, path, message });
|
|
227
|
+
if (!isPlainObject(answer)) { say(DesignerDirectionIssueCode.Shape, '', 'the art direction is the ten lines'); return out; }
|
|
228
|
+
for (const f of ['sentence', 'signature', 'opening', 'notToCopy']) if (!filled(answer[f])) say(DesignerDirectionIssueCode.Empty, f, 'a line, not empty');
|
|
229
|
+
const groups: Array<[string, ReadonlyArray<string>]> = [['type', Object.values(DirectionTypeRole)], ['header', ['rest', 'scrolled', 'phone']], ['motion', ['curve', 'entrance', 'scroll', 'hover']]];
|
|
230
|
+
for (const [group, keys] of groups) {
|
|
231
|
+
const g = answer[group];
|
|
232
|
+
if (!isPlainObject(g)) { say(DesignerDirectionIssueCode.Shape, group, `{ ${keys.join(', ')} }`); continue; }
|
|
233
|
+
for (const k of keys) if (!filled(g[k])) say(DesignerDirectionIssueCode.Empty, `${group}.${k}`, 'a line, not empty');
|
|
234
|
+
}
|
|
235
|
+
const lists: Array<[string, { min: number; max: number }]> = [['grounds', { min: 3, max: 16 }], ['parts', DIRECTION_NAMED_PARTS], ['pictures', DIRECTION_PICTURE_FAMILIES]];
|
|
236
|
+
for (const [f, range] of lists) {
|
|
237
|
+
const v = answer[f];
|
|
238
|
+
if (!Array.isArray(v)) { say(DesignerDirectionIssueCode.Shape, f, 'a list'); continue; }
|
|
239
|
+
if (v.length < range.min || v.length > range.max) say(DesignerDirectionIssueCode.Count, f, `${range.min}–${range.max}, not ${v.length}`);
|
|
240
|
+
}
|
|
241
|
+
const pictures = Array.isArray(answer['pictures']) ? answer['pictures'] as unknown[] : [];
|
|
242
|
+
pictures.forEach((p, i) => { if (!isPlainObject(p) || !filled(p['family']) || !filled(p['mood'])) say(DesignerDirectionIssueCode.Empty, `pictures[${i}]`, 'a family and its mood words'); });
|
|
243
|
+
const motion = isPlainObject(answer['motion']) ? answer['motion'] : {};
|
|
244
|
+
for (const k of ['entrance', 'scroll', 'hover']) {
|
|
245
|
+
if (typeof motion[k] === 'string' && MOTION_FORBIDDEN.test(motion[k] as string)) say(DesignerDirectionIssueCode.Motion, `motion.${k}`, 'motion moves transform and opacity only (Emil) — never size, position or colour');
|
|
246
|
+
}
|
|
247
|
+
return out;
|
|
248
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { AI_STEP_TYPICAL_TOKENS, AiKeyMode, AiStep, AiTokenCounts, costUsd, creditsOfUsd } from './ai-run';
|
|
2
|
+
import { DESIGNER_ROUND_CAPS, DesignerPageRole } from './designer-stop';
|
|
3
|
+
import { outwardCredits, QuoteRoute } from './start-quote';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* WHAT A DESIGNED SITE COSTS, SAID BEFORE BUILD (ai-designer-plan §6b–§6c, AD-D12, R-H11, R-H26; board ai-designer
|
|
7
|
+
* AD-F3, Q4, Q7, Q8) — pure, on the credit estimate's own parts (`QuoteRoute`, `costUsd` → `creditsOfUsd`,
|
|
8
|
+
* `outwardCredits`), never a second pricing.
|
|
9
|
+
*
|
|
10
|
+
* - A ROUND is one critique (the critic's model) and one revise (the designer's), at §6b's tokens.
|
|
11
|
+
* - The pages: each role's expected rounds — the kind's recent average when it has one (R-H11, falling as lessons work),
|
|
12
|
+
* else today's proof rates (§6c: Home 6, an inner page 3, a legal page 1) — never above the role's cap (§2g); a second
|
|
13
|
+
* language is one round per page (§2h).
|
|
14
|
+
* - The three concepts are three rounds (§2a′), inside the total and shown as spent once they are (R-H26); "Try three
|
|
15
|
+
* more" is priced the same, at most twice (Q4).
|
|
16
|
+
* - THE CAP (Q7): twice the BUILD, the concepts outside it — they are already spent and capped by their own price.
|
|
17
|
+
* - THE BALANCE (Q8): a build whose next round the balance cannot pay stops there, keeps its best pages, and offers
|
|
18
|
+
* "Continue · ≈ N credits" after a pack — never refused at Build for a cap above the balance.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** §6b: one critique (≈ 20 pictures, the reference's cached) and one revise (the page as compact ops), per round. */
|
|
22
|
+
export const DESIGNER_ROUND_TOKENS: Readonly<{ critique: AiTokenCounts; revise: AiTokenCounts }> = {
|
|
23
|
+
critique: AI_STEP_TYPICAL_TOKENS[AiStep.DesignCritique],
|
|
24
|
+
revise: AI_STEP_TYPICAL_TOKENS[AiStep.DesignRevise],
|
|
25
|
+
};
|
|
26
|
+
/** §6c: the rounds a page takes at today's proof rates, with the batch A/B fixes and the seeded lessons. */
|
|
27
|
+
export const DESIGNER_ROUNDS_EXPECTED: Readonly<Record<DesignerPageRole, number>> = {
|
|
28
|
+
[DesignerPageRole.Home]: 6,
|
|
29
|
+
[DesignerPageRole.Inner]: 3,
|
|
30
|
+
[DesignerPageRole.Language]: 1,
|
|
31
|
+
[DesignerPageRole.Legal]: 1,
|
|
32
|
+
};
|
|
33
|
+
/** §2a′: the three concepts are sketched in about three rounds. */
|
|
34
|
+
export const DESIGNER_CONCEPT_ROUNDS = 3;
|
|
35
|
+
/** Board Q4: "Try three more" at most this many times (9 directions). */
|
|
36
|
+
export const DESIGNER_MORE_CONCEPTS = 2;
|
|
37
|
+
/** AD-D12, Q7: a build never spends more than this many times its estimate. */
|
|
38
|
+
export const DESIGNER_CAP_OVER_ESTIMATE = 2;
|
|
39
|
+
|
|
40
|
+
/** Who critiques and who revises — each a route as the start quote prices one. */
|
|
41
|
+
export interface DesignerRoutes {
|
|
42
|
+
critique: QuoteRoute | null;
|
|
43
|
+
revise: QuoteRoute | null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface DesignerQuoteInput {
|
|
47
|
+
pages: { home: number; inner: number; legal: number };
|
|
48
|
+
/** Second languages, each one pass over every page (§2h). */
|
|
49
|
+
languages: number;
|
|
50
|
+
/** The kind's recent average rounds per role (AD5's metric) — absent = today's rates. */
|
|
51
|
+
recent?: Partial<Record<DesignerPageRole, number>>;
|
|
52
|
+
/** The concepts were already sketched (their credits are spent). */
|
|
53
|
+
conceptsSpent?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export enum DesignerQuoteRow {
|
|
57
|
+
Concepts = 'concepts',
|
|
58
|
+
Home = 'home',
|
|
59
|
+
Inner = 'inner',
|
|
60
|
+
Legal = 'legal',
|
|
61
|
+
Language = 'language',
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface DesignerQuotePart {
|
|
65
|
+
row: DesignerQuoteRow;
|
|
66
|
+
pages: number;
|
|
67
|
+
/** Rounds per page. */
|
|
68
|
+
rounds: number;
|
|
69
|
+
/** Exact credits (to a millionth). */
|
|
70
|
+
credits: number;
|
|
71
|
+
spent?: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface DesignerQuote {
|
|
75
|
+
/** Whole credits, rounded up: the build (pages + languages), the concepts, and both. */
|
|
76
|
+
build: number;
|
|
77
|
+
concepts: number;
|
|
78
|
+
total: number;
|
|
79
|
+
/** Q7: never more than this for the build. */
|
|
80
|
+
cap: number;
|
|
81
|
+
/** One round's credits (critique + revise), exact. */
|
|
82
|
+
round: number;
|
|
83
|
+
keyMode: `${AiKeyMode}`;
|
|
84
|
+
estimated: boolean;
|
|
85
|
+
parts: DesignerQuotePart[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const up = (credits: number) => outwardCredits(credits, credits).high;
|
|
89
|
+
const routeCredits = (route: QuoteRoute | null, tokens: AiTokenCounts) => (route?.price ? creditsOfUsd(costUsd(tokens, route.price)) : 0);
|
|
90
|
+
|
|
91
|
+
/** One round's credits on these routes. */
|
|
92
|
+
export function designerRoundCredits(routes: DesignerRoutes): number {
|
|
93
|
+
return routeCredits(routes.critique, DESIGNER_ROUND_TOKENS.critique) + routeCredits(routes.revise, DESIGNER_ROUND_TOKENS.revise);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The rounds a role is counted at: the kind's recent average, else today's rate — within 1 and the role's cap. */
|
|
97
|
+
export function expectedRounds(role: DesignerPageRole, recent?: Partial<Record<DesignerPageRole, number>>): number {
|
|
98
|
+
const seen = recent?.[role];
|
|
99
|
+
const rounds = typeof seen === 'number' && seen > 0 ? seen : DESIGNER_ROUNDS_EXPECTED[role];
|
|
100
|
+
return Math.min(DESIGNER_ROUND_CAPS[role], Math.max(1, rounds));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The estimate before Build (AD-F3): its rows, the build, the concepts, the cap. */
|
|
104
|
+
export function designerQuote(input: DesignerQuoteInput, routes: DesignerRoutes): DesignerQuote {
|
|
105
|
+
const round = designerRoundCredits(routes);
|
|
106
|
+
const row = (r: DesignerQuoteRow, pages: number, rounds: number, extra: Partial<DesignerQuotePart> = {}): DesignerQuotePart =>
|
|
107
|
+
({ row: r, pages, rounds, credits: round * pages * rounds, ...extra });
|
|
108
|
+
const { home, inner, legal } = input.pages;
|
|
109
|
+
const parts: DesignerQuotePart[] = [
|
|
110
|
+
row(DesignerQuoteRow.Concepts, 1, DESIGNER_CONCEPT_ROUNDS, input.conceptsSpent ? { spent: true } : {}),
|
|
111
|
+
row(DesignerQuoteRow.Home, home, expectedRounds(DesignerPageRole.Home, input.recent)),
|
|
112
|
+
row(DesignerQuoteRow.Inner, inner, expectedRounds(DesignerPageRole.Inner, input.recent)),
|
|
113
|
+
row(DesignerQuoteRow.Legal, legal, expectedRounds(DesignerPageRole.Legal, input.recent)),
|
|
114
|
+
row(DesignerQuoteRow.Language, (home + inner + legal) * input.languages, expectedRounds(DesignerPageRole.Language, input.recent)),
|
|
115
|
+
].filter(p => p.row === DesignerQuoteRow.Concepts || p.pages > 0);
|
|
116
|
+
const conceptsExact = parts[0].credits;
|
|
117
|
+
const buildExact = parts.slice(1).reduce((s, p) => s + p.credits, 0);
|
|
118
|
+
const priced = [routes.critique, routes.revise].filter((r): r is QuoteRoute => !!r);
|
|
119
|
+
const build = up(buildExact);
|
|
120
|
+
return {
|
|
121
|
+
build,
|
|
122
|
+
concepts: up(conceptsExact),
|
|
123
|
+
total: up(buildExact + conceptsExact),
|
|
124
|
+
cap: DESIGNER_CAP_OVER_ESTIMATE * build,
|
|
125
|
+
round,
|
|
126
|
+
keyMode: priced.length > 0 && priced.every(r => r.keyMode === AiKeyMode.Own) ? AiKeyMode.Own : AiKeyMode.Platform,
|
|
127
|
+
estimated: [routes.critique, routes.revise].some(r => !r || !r.price || r.estimated === true),
|
|
128
|
+
parts,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Board Q4: whether "Try three more" is offered after `tried` times, and its price. */
|
|
133
|
+
export function moreConceptsOffer(tried: number, routes: DesignerRoutes): { offered: boolean; credits: number } {
|
|
134
|
+
return { offered: tried < DESIGNER_MORE_CONCEPTS, credits: up(designerRoundCredits(routes) * DESIGNER_CONCEPT_ROUNDS) };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export enum DesignerSpendStop {
|
|
138
|
+
/** The build reached twice its estimate (`ai.capReached`). */
|
|
139
|
+
Cap = 'cap',
|
|
140
|
+
/** The studio's credits cannot pay the next round (Q8). */
|
|
141
|
+
Balance = 'balance',
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface DesignerSpendInput {
|
|
145
|
+
/** The quote's cap and build (whole credits). */
|
|
146
|
+
cap: number;
|
|
147
|
+
build: number;
|
|
148
|
+
/** What the build has spent so far (exact credits). */
|
|
149
|
+
spent: number;
|
|
150
|
+
/** The next round's credits. */
|
|
151
|
+
next: number;
|
|
152
|
+
/** The studio's credits left (`AiMeter.remaining`); null/absent = unlimited (an own key). */
|
|
153
|
+
balance?: number | null;
|
|
154
|
+
keyMode?: `${AiKeyMode}`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** A rounding margin, as the gate keeps one (a hundred-thousandth of a credit). */
|
|
158
|
+
const CREDIT_SLACK = 1e-5;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Before each round: go on, or stop the build — at the cap (Q7), or at the balance (Q8: keep the best pages, offer to
|
|
162
|
+
* continue for what the estimate has left). An own key is never stopped by the balance.
|
|
163
|
+
*/
|
|
164
|
+
export function designerSpendGate(input: DesignerSpendInput): { go: true } | { go: false; stop: DesignerSpendStop; continueCredits?: number } {
|
|
165
|
+
if (input.spent + input.next > input.cap + CREDIT_SLACK) return { go: false, stop: DesignerSpendStop.Cap };
|
|
166
|
+
const own = input.keyMode === AiKeyMode.Own;
|
|
167
|
+
if (!own && typeof input.balance === 'number' && input.next > input.balance + CREDIT_SLACK) {
|
|
168
|
+
return { go: false, stop: DesignerSpendStop.Balance, continueCredits: up(Math.max(input.next, input.build - input.spent)) };
|
|
169
|
+
}
|
|
170
|
+
return { go: true };
|
|
171
|
+
}
|