@vectoriox/iox-ui 5.203.0 → 5.204.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 (50) hide show
  1. package/actions-core/index.d.ts +8 -1
  2. package/design-core/index.d.ts +62 -2
  3. package/fesm2022/vectoriox-iox-ui-actions-core.mjs +8 -1
  4. package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
  5. package/fesm2022/vectoriox-iox-ui-design-core.mjs +121 -11
  6. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  7. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +5165 -267
  8. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  9. package/fesm2022/vectoriox-iox-ui.mjs +381 -32
  10. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  11. package/generation-core/index.d.ts +2263 -5
  12. package/index.d.ts +117 -12
  13. package/package.json +1 -1
  14. package/src/actions-core/element-actions.ts +9 -0
  15. package/src/design-core/contrast-audit.ts +93 -11
  16. package/src/design-core/flavor-spec.generated.ts +19 -0
  17. package/src/design-core/image-alt.ts +27 -0
  18. package/src/design-core/public-api.ts +1 -0
  19. package/src/generation-core/audit-site.ts +17 -3
  20. package/src/generation-core/baseline-roles.ts +10 -6
  21. package/src/generation-core/check-free.ts +12 -2
  22. package/src/generation-core/check-layout.ts +3 -2
  23. package/src/generation-core/critic-calibration.ts +175 -0
  24. package/src/generation-core/critic-prompt.ts +153 -0
  25. package/src/generation-core/critic-rubric.generated.ts +24 -0
  26. package/src/generation-core/critic-sheet.ts +203 -0
  27. package/src/generation-core/critic.ts +175 -0
  28. package/src/generation-core/design-doc-index.ts +58 -0
  29. package/src/generation-core/design-motion.ts +247 -0
  30. package/src/generation-core/design-ops-check.ts +370 -0
  31. package/src/generation-core/design-ops-of.ts +200 -0
  32. package/src/generation-core/design-ops.model.ts +239 -0
  33. package/src/generation-core/design-ops.schema.ts +122 -0
  34. package/src/generation-core/design-ops.ts +361 -0
  35. package/src/generation-core/design-recipes.ts +58 -0
  36. package/src/generation-core/designer-brief.ts +81 -0
  37. package/src/generation-core/designer-direction.ts +248 -0
  38. package/src/generation-core/designer-estimate.ts +171 -0
  39. package/src/generation-core/designer-lessons.generated.ts +653 -0
  40. package/src/generation-core/designer-lessons.ts +153 -0
  41. package/src/generation-core/designer-stop.ts +94 -0
  42. package/src/generation-core/footer-mix.ts +3 -1
  43. package/src/generation-core/node-baselines.generated.ts +953 -10
  44. package/src/generation-core/public-api.ts +20 -0
  45. package/src/generation-core/site-spec.generated.ts +73 -11
  46. package/src/generation-core/social-links.ts +195 -2
  47. package/src/generation-core/structure-fingerprint.ts +565 -0
  48. package/src/generation-core/templates.ts +39 -3
  49. package/styles/iox-design.css +26 -1
  50. package/styles/iox-forms.css +22 -0
@@ -0,0 +1,153 @@
1
+ import { CRITIC_DIMENSIONS, CriticDimension } from './critic';
2
+ import { DESIGNER_LESSONS_SEED } from './designer-lessons.generated';
3
+ import { isPlainObject, PathIssue } from './shape-check';
4
+
5
+ /**
6
+ * THE AI DESIGNER'S LESSONS (ai-designer-plan §3a, AD-D7, R-H11): rules a designer applies while WRITING round 1, each
7
+ * one a critique that moved a score. Seeded from the designer-loop proof (law HARNESS §4b + §4c, hotel HARNESS §4),
8
+ * kept as data in iox-ai-guidance `architecture/ai/designer-lessons.json` and ported by `gen:designer-lessons` until the
9
+ * control-plane store (AD5) holds them.
10
+ * - APPLIED by `lessonsForPrompt`: the approved lessons for the site's kind (and language), ordered by
11
+ * `weight × score moved`, cut at a token budget — the lowest-ranked drop out first.
12
+ * - WEIGHT follows the source: the critic's own 1, the tester's 2, Doron's 3.
13
+ * - RETIRED when the gap behind it ships (`retiresWith` names it) or when Doron marks it wrong — `status: 'retired'`.
14
+ * Pure.
15
+ */
16
+
17
+ export enum LessonSource {
18
+ Critic = 'critic',
19
+ Tester = 'tester',
20
+ Doron = 'doron',
21
+ }
22
+ export const LESSON_WEIGHT: Readonly<Record<LessonSource, number>> = {
23
+ [LessonSource.Critic]: 1,
24
+ [LessonSource.Tester]: 2,
25
+ [LessonSource.Doron]: 3,
26
+ };
27
+ export enum LessonStatus {
28
+ /** Proposed by the critic, waiting for the weekly approval (AD-D7). */
29
+ Proposed = 'proposed',
30
+ Approved = 'approved',
31
+ Retired = 'retired',
32
+ }
33
+ /** The kinds a lesson is for: every kind, or the named business kinds. */
34
+ export const LESSON_ALL_KINDS = 'all';
35
+ /** §3a: a lesson is written when a round moved a dimension by at least this much. */
36
+ export const LESSON_MIN_MOVE = 0.5;
37
+ /** A lesson's floor in the ranking, so one whose round held the score (a rule kept) still ranks by its weight. */
38
+ const LESSON_MOVE_FLOOR = 0.1;
39
+ /** About this many characters to a token (a budget, not a bill). */
40
+ const CHARS_PER_TOKEN = 4;
41
+
42
+ export interface DesignerLesson {
43
+ readonly id: string;
44
+ /** One sentence a designer applies while writing round 1. */
45
+ readonly rule: string;
46
+ readonly kinds: ReadonlyArray<string>;
47
+ /** Only for these site languages (absent = every language). */
48
+ readonly locales?: ReadonlyArray<string>;
49
+ readonly dimension: `${CriticDimension}`;
50
+ /** The round it came from: the score before and after (the dimension's, else the page's mean). */
51
+ readonly evidence: { readonly build: string; readonly round: string; readonly scoreBefore: number; readonly scoreAfter: number; readonly ref?: string };
52
+ readonly source: `${LessonSource}`;
53
+ readonly weight: number;
54
+ readonly status: `${LessonStatus}`;
55
+ /** The builder gap whose fix retires it (§3a). */
56
+ readonly retiresWith?: string;
57
+ }
58
+
59
+ /** The seed, checked against this type at compile time. */
60
+ export const DESIGNER_LESSONS: ReadonlyArray<DesignerLesson> = DESIGNER_LESSONS_SEED;
61
+
62
+ export enum LessonIssueCode {
63
+ Shape = 'shape',
64
+ Duplicate = 'duplicate',
65
+ Dimension = 'dimension',
66
+ Weight = 'weight',
67
+ Evidence = 'evidence',
68
+ }
69
+ export type LessonIssue = PathIssue<LessonIssueCode>;
70
+
71
+ const filled = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0;
72
+ const SOURCES: ReadonlySet<string> = new Set(Object.values(LessonSource));
73
+ const STATUSES: ReadonlySet<string> = new Set(Object.values(LessonStatus));
74
+ const DIMENSIONS: ReadonlySet<string> = new Set(CRITIC_DIMENSIONS);
75
+
76
+ /** A lesson list, judged: each a rule, kinds, a known dimension, evidence with both scores, the source's weight; ids unique. */
77
+ export function designerLessonsIssues(lessons: unknown): LessonIssue[] {
78
+ const out: LessonIssue[] = [];
79
+ const say = (code: LessonIssueCode, path: string, message: string) => out.push({ code, path, message });
80
+ if (!Array.isArray(lessons)) { say(LessonIssueCode.Shape, '', 'a list of lessons'); return out; }
81
+ const ids = new Set<string>();
82
+ lessons.forEach((l: unknown, i) => {
83
+ const path = `[${i}]`;
84
+ if (!isPlainObject(l) || !filled(l['id']) || !filled(l['rule']) || !Array.isArray(l['kinds']) || l['kinds'].length === 0
85
+ || !l['kinds'].every(filled) || !SOURCES.has(l['source'] as string) || !STATUSES.has(l['status'] as string)) {
86
+ say(LessonIssueCode.Shape, path, 'a lesson is { id, rule, kinds (≥ 1), dimension, evidence, source, weight, status }');
87
+ return;
88
+ }
89
+ if (ids.has(l['id'] as string)) say(LessonIssueCode.Duplicate, `${path}.id`, `"${l['id']}" twice`);
90
+ ids.add(l['id'] as string);
91
+ if (!DIMENSIONS.has(l['dimension'] as string)) say(LessonIssueCode.Dimension, `${path}.dimension`, `one of ${CRITIC_DIMENSIONS.join(', ')}`);
92
+ if (l['weight'] !== LESSON_WEIGHT[l['source'] as LessonSource]) say(LessonIssueCode.Weight, `${path}.weight`, `a ${l['source']} lesson weighs ${LESSON_WEIGHT[l['source'] as LessonSource]}`);
93
+ const e = l['evidence'];
94
+ if (!isPlainObject(e) || !filled(e['build']) || !filled(e['round']) || typeof e['scoreBefore'] !== 'number' || typeof e['scoreAfter'] !== 'number') {
95
+ say(LessonIssueCode.Evidence, `${path}.evidence`, 'the round it came from: { build, round, scoreBefore, scoreAfter }');
96
+ }
97
+ });
98
+ return out;
99
+ }
100
+
101
+ /** What a lesson is worth in the prompt: its weight times the score it moved (floored, so a held score still ranks). */
102
+ export function lessonRank(lesson: DesignerLesson): number {
103
+ return lesson.weight * Math.max(LESSON_MOVE_FLOOR, lesson.evidence.scoreAfter - lesson.evidence.scoreBefore);
104
+ }
105
+
106
+ /** A lesson as the prompt reads it: one line. */
107
+ export function lessonLine(lesson: DesignerLesson): string {
108
+ return `- [${lesson.dimension}] ${lesson.rule}`;
109
+ }
110
+
111
+ /** Roughly how many tokens a text costs (a budget, not a bill). */
112
+ export function roughTokens(text: string): number {
113
+ return Math.ceil(text.length / CHARS_PER_TOKEN);
114
+ }
115
+
116
+ export interface LessonsForPrompt {
117
+ /** The lines, best first, one per lesson. */
118
+ text: string;
119
+ used: string[];
120
+ /** Approved lessons for this kind and language that did not fit the budget, best first. */
121
+ dropped: string[];
122
+ tokens: number;
123
+ }
124
+
125
+ /**
126
+ * The lessons the designer's (cached) system prompt carries for a site of `kind` in `locale`: approved, for every kind
127
+ * or this one, for every language or this one; best first by `weight × score moved`; cut at `budget` tokens — the
128
+ * lowest-ranked drop first (a prefix of the ranking, so a short lesson never jumps a better long one).
129
+ */
130
+ export function lessonsForPrompt(kind: string, budget: number, options: { locale?: string; lessons?: ReadonlyArray<DesignerLesson> } = {}): LessonsForPrompt {
131
+ const lessons = options.lessons ?? DESIGNER_LESSONS;
132
+ const ranked = lessons
133
+ .filter(l => l.status === LessonStatus.Approved)
134
+ .filter(l => l.kinds.includes(LESSON_ALL_KINDS) || l.kinds.includes(kind))
135
+ .filter(l => !l.locales || (options.locale !== undefined && l.locales.includes(options.locale)))
136
+ .map((l, at) => ({ l, at, rank: lessonRank(l) }))
137
+ .sort((a, b) => b.rank - a.rank || a.at - b.at)
138
+ .map(r => r.l);
139
+ const used: DesignerLesson[] = [];
140
+ let tokens = 0;
141
+ for (const l of ranked) {
142
+ const cost = roughTokens(`${lessonLine(l)}\n`);
143
+ if (tokens + cost > budget) break;
144
+ used.push(l);
145
+ tokens += cost;
146
+ }
147
+ return {
148
+ text: used.map(lessonLine).join('\n'),
149
+ used: used.map(l => l.id),
150
+ dropped: ranked.slice(used.length).map(l => l.id),
151
+ tokens,
152
+ };
153
+ }
@@ -0,0 +1,94 @@
1
+ import { CRITIC_DIMENSIONS, CriticAnswer, criticVerdict } from './critic';
2
+ import { CRITIC_RUBRIC_POLISH } from './critic-rubric.generated';
3
+ import { FreedomIssue } from './structure-fingerprint';
4
+
5
+ /**
6
+ * THE STOP RULE (ai-designer-plan §2g, AD-D6, R-H10), as code. A page stops at the first of:
7
+ * 1. DONE — the calibrated mean ≥ 8, no dimension under 7.5, nothing capping it (a broken bug, a copy, a repeat), the
8
+ * gate 0 blocking / 0 asking;
9
+ * 2. FLAT — two rounds in a row that moved the score less than +0.2;
10
+ * 3. BUDGET — the page's round cap (Home 6, an inner page 4, a language pass 1, a legal page 1), or the build's credits
11
+ * (`designerSpendGate`) said stop.
12
+ * The round that is written is the BEST one, not necessarily the last: the highest score, the later on a tie (it holds
13
+ * more of the fixes for the same score). Pure.
14
+ */
15
+
16
+ export const DESIGNER_DONE = { mean: 8, floor: 7.5 } as const;
17
+ /** FLAT: a round moved the score less than this… */
18
+ export const DESIGNER_FLAT_STEP = 0.2;
19
+ /** …this many rounds in a row. */
20
+ export const DESIGNER_FLAT_ROUNDS = 2;
21
+
22
+ /** What a page is, to the stop rule (§2g's caps). */
23
+ export enum DesignerPageRole {
24
+ Home = 'home',
25
+ Inner = 'inner',
26
+ /** A second language's pass over a page already stopped (§2h). */
27
+ Language = 'language',
28
+ Legal = 'legal',
29
+ }
30
+ export const DESIGNER_ROUND_CAPS: Readonly<Record<DesignerPageRole, number>> = {
31
+ [DesignerPageRole.Home]: 6,
32
+ [DesignerPageRole.Inner]: 4,
33
+ [DesignerPageRole.Language]: 1,
34
+ [DesignerPageRole.Legal]: 1,
35
+ };
36
+
37
+ export enum DesignerStop {
38
+ Done = 'done',
39
+ Flat = 'flat',
40
+ Budget = 'budget',
41
+ }
42
+
43
+ /** One round, as the stop rule reads it: the critic's (calibrated) answer, the gate's counts, the fingerprint's findings. */
44
+ export interface DesignerRound {
45
+ critique: CriticAnswer;
46
+ gate: { blocking: number; asking: number };
47
+ /** A copy or a repeat (designFreedomIssues) — it caps the page like a broken bug (AD-D19). */
48
+ freedom?: ReadonlyArray<FreedomIssue>;
49
+ }
50
+
51
+ /** A round's score: the critic's headline, capped at the broken cap when the page copies or repeats (AD-D19). */
52
+ export interface DesignerRoundScore {
53
+ headline: number;
54
+ designMean: number;
55
+ lowest: number;
56
+ capped: boolean;
57
+ done: boolean;
58
+ }
59
+
60
+ export function designerRoundScore(round: DesignerRound): DesignerRoundScore {
61
+ const verdict = criticVerdict(round.critique);
62
+ const freedom = (round.freedom?.length ?? 0) > 0;
63
+ const capped = verdict.capped || verdict.broken > 0 || freedom;
64
+ const headline = freedom ? Math.min(verdict.headline, CRITIC_RUBRIC_POLISH.brokenCap) : verdict.headline;
65
+ const lowest = Math.min(...CRITIC_DIMENSIONS.map(d => round.critique.scores[d].score));
66
+ const done = verdict.designMean >= DESIGNER_DONE.mean && lowest >= DESIGNER_DONE.floor && !capped
67
+ && round.gate.blocking === 0 && round.gate.asking === 0;
68
+ return { headline, designMean: verdict.designMean, lowest, capped, done };
69
+ }
70
+
71
+ export interface DesignerStopDecision {
72
+ /** Null while the page goes on. */
73
+ stop: DesignerStop | null;
74
+ /** The round to write (the best so far); null before any round. */
75
+ best: number | null;
76
+ scores: DesignerRoundScore[];
77
+ }
78
+
79
+ /**
80
+ * After each round: stop or go on, and which round is the best. `outOfCredits` is the build's spend gate saying stop
81
+ * (`designerSpendGate`) — a Budget stop like the page's cap.
82
+ */
83
+ export function designerStopDecision(rounds: ReadonlyArray<DesignerRound>, role: DesignerPageRole, outOfCredits = false): DesignerStopDecision {
84
+ const scores = rounds.map(designerRoundScore);
85
+ let best: number | null = null;
86
+ scores.forEach((s, i) => { if (best === null || s.headline >= scores[best].headline) best = i; });
87
+ const last = scores.length - 1;
88
+ let stop: DesignerStop | null = null;
89
+ if (last >= 0 && scores[last].done) stop = DesignerStop.Done;
90
+ else if (last >= DESIGNER_FLAT_ROUNDS
91
+ && Array.from({ length: DESIGNER_FLAT_ROUNDS }, (_, k) => scores[last - k].headline - scores[last - k - 1].headline).every(step => step < DESIGNER_FLAT_STEP)) stop = DesignerStop.Flat;
92
+ else if (scores.length >= DESIGNER_ROUND_CAPS[role] || outOfCredits) stop = DesignerStop.Budget;
93
+ return { stop, best, scores };
94
+ }
@@ -535,7 +535,9 @@ function statementPhoneLines(tagline: string, ctx: FooterContext): number {
535
535
  }
536
536
 
537
537
  /** FV1b (FV-D10): a network the footer can name a social link by — the contract's `FOOTER.socialNetworks`. */
538
- export interface FooterSocialNetwork { readonly id: string; readonly name: string; readonly hosts: ReadonlyArray<string> }
538
+ /** A network the footer names (`FOOTER.socialNetworks`): its id, its brand name, the hosts an address is recognised by and
539
+ * its Phosphor glyph (`ph-instagram-logo` — a follow row whose link the owner made an icon wears it; iox-ui#201). */
540
+ export interface FooterSocialNetwork { readonly id: string; readonly name: string; readonly hosts: ReadonlyArray<string>; readonly icon?: string }
539
541
  export const FOOTER_SOCIAL_NETWORKS = (F as unknown as { socialNetworks: ReadonlyArray<FooterSocialNetwork> }).socialNetworks;
540
542
 
541
543
  /** One social link the footer shows: the network's name and the owner's address (https). */