@koda-sl/baker-cli 0.483.0-dev.6a297fc5c → 0.484.0-dev.31cacb0d1
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/dist/{brief-MNWFEJ3L.js → brief-4WIMY6AT.js} +8 -8
- package/dist/{canvas-TTV7QZZT.js → canvas-YV374OWM.js} +13 -13
- package/dist/{catalog-43BSTAT6.js → catalog-KZNB2YJS.js} +3 -3
- package/dist/{check-545MAB4E.js → check-M2SBGDW6.js} +5 -5
- package/dist/{chunk-RMNKCVRB.js → chunk-2GT76KEX.js} +14 -4
- package/dist/chunk-2GT76KEX.js.map +1 -0
- package/dist/{chunk-TY4BDVLG.js → chunk-3VCHJN2B.js} +6 -3
- package/dist/chunk-3VCHJN2B.js.map +1 -0
- package/dist/{chunk-C7MENOP5.js → chunk-4C55EB4J.js} +6 -6
- package/dist/{chunk-PNVEV3XP.js → chunk-5VJK7NMF.js} +24 -13
- package/dist/chunk-5VJK7NMF.js.map +1 -0
- package/dist/{chunk-3ZHOBEQD.js → chunk-7RPJTHHD.js} +2 -2
- package/dist/{chunk-YU2XIIL3.js → chunk-AQZO3LKT.js} +5 -5
- package/dist/{chunk-ROX7LQRR.js → chunk-C7WPAUIJ.js} +2 -2
- package/dist/{chunk-ZJ6HUCRK.js → chunk-CN4YK7IU.js} +2 -2
- package/dist/{chunk-XF5R2FQT.js → chunk-DBJ3GK5X.js} +13 -13
- package/dist/{chunk-TGIL4L4L.js → chunk-ERYVGW6A.js} +4 -4
- package/dist/{chunk-GJWMPTUE.js → chunk-ET6GJ6OS.js} +2 -2
- package/dist/{chunk-KXSXZAC2.js → chunk-GYJQV3IX.js} +2 -2
- package/dist/{chunk-XFJNCZXA.js → chunk-I5XXOMMR.js} +4 -4
- package/dist/{chunk-REMR5FHD.js → chunk-LHUIYOSF.js} +2 -2
- package/dist/{chunk-QKABEX3F.js → chunk-MP5IMGKF.js} +2 -2
- package/dist/{chunk-GM46ZEYP.js → chunk-O5SMBTBG.js} +3 -3
- package/dist/{chunk-WHSTZRUY.js → chunk-P5ENZXC2.js} +2 -2
- package/dist/{chunk-2WTD5Y34.js → chunk-PPRHZAHX.js} +3 -3
- package/dist/{chunk-UTLIQBRY.js → chunk-SKQCKPBL.js} +3 -3
- package/dist/{chunk-QTLZXIF3.js → chunk-TFJW5CXD.js} +4 -2
- package/dist/chunk-TFJW5CXD.js.map +1 -0
- package/dist/{chunk-U63S2JWI.js → chunk-WY5H3XYC.js} +2 -2
- package/dist/{chunk-64HQDJ2E.js → chunk-YGDJGSJQ.js} +2 -2
- package/dist/{chunk-HNEYIWXW.js → chunk-YSB26POP.js} +29 -11
- package/dist/chunk-YSB26POP.js.map +1 -0
- package/dist/{chunk-TBHRRQZD.js → chunk-ZC6FKVRD.js} +5 -5
- package/dist/{chunk-DDES6J6A.js → chunk-ZTHXYQTZ.js} +4 -4
- package/dist/cli.js +3 -3
- package/dist/{creatives-ZOK7PZSG.js → creatives-4MIF42HZ.js} +10 -10
- package/dist/{critique-OCVV6N3U.js → critique-2RT2HVZY.js} +8 -8
- package/dist/engine/index.d.ts +1 -0
- package/dist/engine/index.js +2 -2
- package/dist/{feedback-GAGIKZ6B.js → feedback-EHBCJT3T.js} +11 -11
- package/dist/{feedback-record-ZORDBRV2.js → feedback-record-5ZCV6YV2.js} +12 -12
- package/dist/{fit-DGCYW7LN.js → fit-XYUZEL5W.js} +5 -5
- package/dist/{ideas-NBQPCC5C.js → ideas-WYNF7WWA.js} +5 -5
- package/dist/{learn-6HVDSTTJ.js → learn-KYO2MAKF.js} +4 -4
- package/dist/{make-EWHS4EHQ.js → make-4RNN3G5H.js} +31 -23
- package/dist/make-4RNN3G5H.js.map +1 -0
- package/dist/{rerun-ETH2NEEX.js → rerun-SBDJBDG7.js} +16 -16
- package/dist/{rules-KEHQEXEU.js → rules-SNLFT4U7.js} +5 -5
- package/dist/{rules-add-IDBWO6XV.js → rules-add-XH6CAHHI.js} +4 -4
- package/dist/{run-FFASB4YB.js → run-7QB7Z3ZK.js} +16 -16
- package/dist/{scaffold-ad-EKCXHZPT.js → scaffold-ad-XL5TJT3Q.js} +13 -13
- package/dist/{scaffold-static-ad-MWKTXATN.js → scaffold-static-ad-OXUYUIHB.js} +20 -20
- package/dist/{scaffold-video-BYPPH352.js → scaffold-video-O5IYM5UG.js} +12 -12
- package/dist/{select-CPFKK57J.js → select-FUVRFVI6.js} +10 -10
- package/dist/{set-prompt-TJ3UTNYS.js → set-prompt-B2OGYEUM.js} +9 -9
- package/dist/{stale-KILEXX57.js → stale-F7POC6G7.js} +9 -9
- package/dist/{sync-definition-DGSAZGQZ.js → sync-definition-WBCK3PQ3.js} +12 -12
- package/dist/{translate-C5LZ6KVN.js → translate-E64XLMG6.js} +13 -13
- package/dist/{validate-KPJLIGYY.js → validate-HB74PHZQ.js} +12 -12
- package/dist/{viewer-check-2GI26EKA.js → viewer-check-EUDPWB3W.js} +6 -6
- package/dist/{winning-ads-6SXA4HGB.js → winning-ads-MET3ZAL7.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-HNEYIWXW.js.map +0 -1
- package/dist/chunk-PNVEV3XP.js.map +0 -1
- package/dist/chunk-QTLZXIF3.js.map +0 -1
- package/dist/chunk-RMNKCVRB.js.map +0 -1
- package/dist/chunk-TY4BDVLG.js.map +0 -1
- package/dist/make-EWHS4EHQ.js.map +0 -1
- /package/dist/{brief-MNWFEJ3L.js.map → brief-4WIMY6AT.js.map} +0 -0
- /package/dist/{canvas-TTV7QZZT.js.map → canvas-YV374OWM.js.map} +0 -0
- /package/dist/{catalog-43BSTAT6.js.map → catalog-KZNB2YJS.js.map} +0 -0
- /package/dist/{check-545MAB4E.js.map → check-M2SBGDW6.js.map} +0 -0
- /package/dist/{chunk-C7MENOP5.js.map → chunk-4C55EB4J.js.map} +0 -0
- /package/dist/{chunk-3ZHOBEQD.js.map → chunk-7RPJTHHD.js.map} +0 -0
- /package/dist/{chunk-YU2XIIL3.js.map → chunk-AQZO3LKT.js.map} +0 -0
- /package/dist/{chunk-ROX7LQRR.js.map → chunk-C7WPAUIJ.js.map} +0 -0
- /package/dist/{chunk-ZJ6HUCRK.js.map → chunk-CN4YK7IU.js.map} +0 -0
- /package/dist/{chunk-XF5R2FQT.js.map → chunk-DBJ3GK5X.js.map} +0 -0
- /package/dist/{chunk-TGIL4L4L.js.map → chunk-ERYVGW6A.js.map} +0 -0
- /package/dist/{chunk-GJWMPTUE.js.map → chunk-ET6GJ6OS.js.map} +0 -0
- /package/dist/{chunk-KXSXZAC2.js.map → chunk-GYJQV3IX.js.map} +0 -0
- /package/dist/{chunk-XFJNCZXA.js.map → chunk-I5XXOMMR.js.map} +0 -0
- /package/dist/{chunk-REMR5FHD.js.map → chunk-LHUIYOSF.js.map} +0 -0
- /package/dist/{chunk-QKABEX3F.js.map → chunk-MP5IMGKF.js.map} +0 -0
- /package/dist/{chunk-GM46ZEYP.js.map → chunk-O5SMBTBG.js.map} +0 -0
- /package/dist/{chunk-WHSTZRUY.js.map → chunk-P5ENZXC2.js.map} +0 -0
- /package/dist/{chunk-2WTD5Y34.js.map → chunk-PPRHZAHX.js.map} +0 -0
- /package/dist/{chunk-UTLIQBRY.js.map → chunk-SKQCKPBL.js.map} +0 -0
- /package/dist/{chunk-U63S2JWI.js.map → chunk-WY5H3XYC.js.map} +0 -0
- /package/dist/{chunk-64HQDJ2E.js.map → chunk-YGDJGSJQ.js.map} +0 -0
- /package/dist/{chunk-TBHRRQZD.js.map → chunk-ZC6FKVRD.js.map} +0 -0
- /package/dist/{chunk-DDES6J6A.js.map → chunk-ZTHXYQTZ.js.map} +0 -0
- /package/dist/{creatives-ZOK7PZSG.js.map → creatives-4MIF42HZ.js.map} +0 -0
- /package/dist/{critique-OCVV6N3U.js.map → critique-2RT2HVZY.js.map} +0 -0
- /package/dist/{feedback-GAGIKZ6B.js.map → feedback-EHBCJT3T.js.map} +0 -0
- /package/dist/{feedback-record-ZORDBRV2.js.map → feedback-record-5ZCV6YV2.js.map} +0 -0
- /package/dist/{fit-DGCYW7LN.js.map → fit-XYUZEL5W.js.map} +0 -0
- /package/dist/{ideas-NBQPCC5C.js.map → ideas-WYNF7WWA.js.map} +0 -0
- /package/dist/{learn-6HVDSTTJ.js.map → learn-KYO2MAKF.js.map} +0 -0
- /package/dist/{rerun-ETH2NEEX.js.map → rerun-SBDJBDG7.js.map} +0 -0
- /package/dist/{rules-KEHQEXEU.js.map → rules-SNLFT4U7.js.map} +0 -0
- /package/dist/{rules-add-IDBWO6XV.js.map → rules-add-XH6CAHHI.js.map} +0 -0
- /package/dist/{run-FFASB4YB.js.map → run-7QB7Z3ZK.js.map} +0 -0
- /package/dist/{scaffold-ad-EKCXHZPT.js.map → scaffold-ad-XL5TJT3Q.js.map} +0 -0
- /package/dist/{scaffold-static-ad-MWKTXATN.js.map → scaffold-static-ad-OXUYUIHB.js.map} +0 -0
- /package/dist/{scaffold-video-BYPPH352.js.map → scaffold-video-O5IYM5UG.js.map} +0 -0
- /package/dist/{select-CPFKK57J.js.map → select-FUVRFVI6.js.map} +0 -0
- /package/dist/{set-prompt-TJ3UTNYS.js.map → set-prompt-B2OGYEUM.js.map} +0 -0
- /package/dist/{stale-KILEXX57.js.map → stale-F7POC6G7.js.map} +0 -0
- /package/dist/{sync-definition-DGSAZGQZ.js.map → sync-definition-WBCK3PQ3.js.map} +0 -0
- /package/dist/{translate-C5LZ6KVN.js.map → translate-E64XLMG6.js.map} +0 -0
- /package/dist/{validate-KPJLIGYY.js.map → validate-HB74PHZQ.js.map} +0 -0
- /package/dist/{viewer-check-2GI26EKA.js.map → viewer-check-EUDPWB3W.js.map} +0 -0
- /package/dist/{winning-ads-6SXA4HGB.js.map → winning-ads-MET3ZAL7.js.map} +0 -0
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
buildNext,
|
|
9
9
|
ideasReport
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ERYVGW6A.js";
|
|
11
11
|
import {
|
|
12
12
|
buildSearchBody
|
|
13
13
|
} from "./chunk-MXWOYFI2.js";
|
|
@@ -18,22 +18,22 @@ import {
|
|
|
18
18
|
} from "./chunk-AOZ7547I.js";
|
|
19
19
|
import {
|
|
20
20
|
readInsights
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-MP5IMGKF.js";
|
|
22
22
|
import {
|
|
23
23
|
liveViewerLookups
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-O5SMBTBG.js";
|
|
25
|
+
import "./chunk-I5XXOMMR.js";
|
|
26
|
+
import "./chunk-CN4YK7IU.js";
|
|
27
27
|
import "./chunk-LCW3U4EA.js";
|
|
28
28
|
import {
|
|
29
29
|
readAllRules,
|
|
30
30
|
readCompanyReading
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-YGDJGSJQ.js";
|
|
32
32
|
import {
|
|
33
33
|
AWARENESS_STAGES,
|
|
34
34
|
IDEA_ANGLES,
|
|
35
35
|
IDEA_FORMATS
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-3VCHJN2B.js";
|
|
37
37
|
import {
|
|
38
38
|
researchCustomers
|
|
39
39
|
} from "./chunk-FQXGII24.js";
|
|
@@ -535,4 +535,4 @@ export {
|
|
|
535
535
|
tastePart,
|
|
536
536
|
whatWorks
|
|
537
537
|
};
|
|
538
|
-
//# sourceMappingURL=brief-
|
|
538
|
+
//# sourceMappingURL=brief-4WIMY6AT.js.map
|
|
@@ -25,22 +25,22 @@ Subcommands:
|
|
|
25
25
|
Full guide: __tooling__/docs/tools/baker/canvas.md`
|
|
26
26
|
},
|
|
27
27
|
subCommands: {
|
|
28
|
-
run: () => import("./run-
|
|
29
|
-
rerun: () => import("./rerun-
|
|
30
|
-
validate: () => import("./validate-
|
|
31
|
-
critique: () => import("./critique-
|
|
32
|
-
"viewer-check": () => import("./viewer-check-
|
|
33
|
-
catalog: () => import("./catalog-
|
|
28
|
+
run: () => import("./run-7QB7Z3ZK.js").then((m) => m.runCommand),
|
|
29
|
+
rerun: () => import("./rerun-SBDJBDG7.js").then((m) => m.rerunCommand),
|
|
30
|
+
validate: () => import("./validate-HB74PHZQ.js").then((m) => m.validateCommand),
|
|
31
|
+
critique: () => import("./critique-2RT2HVZY.js").then((m) => m.critiqueCommand),
|
|
32
|
+
"viewer-check": () => import("./viewer-check-EUDPWB3W.js").then((m) => m.viewerCheckCommand),
|
|
33
|
+
catalog: () => import("./catalog-KZNB2YJS.js").then((m) => m.catalogCommand),
|
|
34
34
|
inspect: () => import("./inspect-5PRLZLF5.js").then((m) => m.inspectCommand),
|
|
35
|
-
"scaffold-ad": () => import("./scaffold-ad-
|
|
36
|
-
"scaffold-video": () => import("./scaffold-video-
|
|
37
|
-
"scaffold-static-ad": () => import("./scaffold-static-ad-
|
|
38
|
-
"set-prompt": () => import("./set-prompt-
|
|
39
|
-
"sync-definition": () => import("./sync-definition-
|
|
40
|
-
stale: () => import("./stale-
|
|
35
|
+
"scaffold-ad": () => import("./scaffold-ad-XL5TJT3Q.js").then((m) => m.scaffoldAdCommand),
|
|
36
|
+
"scaffold-video": () => import("./scaffold-video-O5IYM5UG.js").then((m) => m.scaffoldVideoCommand),
|
|
37
|
+
"scaffold-static-ad": () => import("./scaffold-static-ad-OXUYUIHB.js").then((m) => m.scaffoldStaticAdCommand),
|
|
38
|
+
"set-prompt": () => import("./set-prompt-B2OGYEUM.js").then((m) => m.setPromptCommand),
|
|
39
|
+
"sync-definition": () => import("./sync-definition-WBCK3PQ3.js").then((m) => m.syncDefinitionCommand),
|
|
40
|
+
stale: () => import("./stale-F7POC6G7.js").then((m) => m.staleCommand)
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
export {
|
|
44
44
|
canvasCommand
|
|
45
45
|
};
|
|
46
|
-
//# sourceMappingURL=canvas-
|
|
46
|
+
//# sourceMappingURL=canvas-YV374OWM.js.map
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
catalogView,
|
|
3
3
|
defaultRegistry,
|
|
4
4
|
generateCatalog
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-YSB26POP.js";
|
|
6
|
+
import "./chunk-TFJW5CXD.js";
|
|
7
7
|
import "./chunk-XLJVJ5TK.js";
|
|
8
8
|
import "./chunk-DGCUPJZD.js";
|
|
9
9
|
import "./chunk-I2WRZJAC.js";
|
|
@@ -62,4 +62,4 @@ var catalogCommand = defineCommand({
|
|
|
62
62
|
export {
|
|
63
63
|
catalogCommand
|
|
64
64
|
};
|
|
65
|
-
//# sourceMappingURL=catalog-
|
|
65
|
+
//# sourceMappingURL=catalog-KZNB2YJS.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readAdWords,
|
|
3
3
|
ruleRefusal
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-I5XXOMMR.js";
|
|
5
|
+
import "./chunk-CN4YK7IU.js";
|
|
6
6
|
import "./chunk-LCW3U4EA.js";
|
|
7
7
|
import {
|
|
8
8
|
readAllRules
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YGDJGSJQ.js";
|
|
10
10
|
import {
|
|
11
11
|
ruleTells
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-3VCHJN2B.js";
|
|
13
13
|
import "./chunk-RGX7AQ2K.js";
|
|
14
14
|
import "./chunk-5WMTPYKT.js";
|
|
15
15
|
import {
|
|
@@ -101,4 +101,4 @@ export {
|
|
|
101
101
|
checkCommand,
|
|
102
102
|
checkCreatives
|
|
103
103
|
};
|
|
104
|
-
//# sourceMappingURL=check-
|
|
104
|
+
//# sourceMappingURL=check-M2SBGDW6.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
IDEA_VIDEO_FORMATS,
|
|
3
3
|
figuresIn,
|
|
4
4
|
unsourcedClaims
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-3VCHJN2B.js";
|
|
6
6
|
import {
|
|
7
7
|
AD_SPEC_SCHEMA,
|
|
8
8
|
unfitReasons
|
|
@@ -53,15 +53,24 @@ function referenceSearchesFor(idea, temperature, where = {}) {
|
|
|
53
53
|
const { country: _shownCountry, ...anyCategoryAnywhere } = anyCategory;
|
|
54
54
|
const { country: _viewerCountry, ...anyViewerAnywhere } = anyViewer;
|
|
55
55
|
const { formatPattern: _anyPattern, ...shownAnyViewer } = anyViewerAnywhere;
|
|
56
|
+
const kinds = (where.shows ?? []).flatMap((q) => q.trim() ? [{ ...anyCategoryAnywhere, query: q.trim() }] : []);
|
|
56
57
|
const shown = shows ? [
|
|
57
58
|
...inMarket([{ ...anyCategory, query: shows }]),
|
|
59
|
+
...kinds,
|
|
58
60
|
{ ...anyCategoryAnywhere, query: shows },
|
|
59
61
|
{ ...shownAnyViewer, query: shows },
|
|
60
62
|
...idea.format ? [{ ...anyViewerAnywhere, query: shows }] : []
|
|
61
63
|
] : [];
|
|
62
64
|
const anyAd = (query) => query?.trim() ? [...inMarket([{ ...anyContainer, query: query.trim() }]), { ...anyContainerAnywhere, query: query.trim() }] : [];
|
|
65
|
+
if (shows) {
|
|
66
|
+
return [
|
|
67
|
+
...shown,
|
|
68
|
+
...where.category ? [anyContainerAnywhere] : [],
|
|
69
|
+
...where.audience?.trim() ? [{ ...anyContainerAnywhere, query: where.audience.trim() }] : [],
|
|
70
|
+
{ ...winnersAnywhere, sort: "winner" }
|
|
71
|
+
];
|
|
72
|
+
}
|
|
63
73
|
return [
|
|
64
|
-
...shown,
|
|
65
74
|
...where.country ? [strict, anyStage, anyContainer] : [strict, anyStage],
|
|
66
75
|
anywhere,
|
|
67
76
|
anyContainerAnywhere,
|
|
@@ -82,7 +91,8 @@ function referenceWhereOf(brief, fallback) {
|
|
|
82
91
|
category: brief.category,
|
|
83
92
|
...brief.industry ? { industry: brief.industry } : {},
|
|
84
93
|
...audience ? { audience } : {},
|
|
85
|
-
...brief.wider.length ? { wider: brief.wider } : {}
|
|
94
|
+
...brief.wider.length ? { wider: brief.wider } : {},
|
|
95
|
+
...brief.shows?.length ? { shows: brief.shows } : {}
|
|
86
96
|
};
|
|
87
97
|
}
|
|
88
98
|
function rankedForOf(brief, where, bet) {
|
|
@@ -272,4 +282,4 @@ export {
|
|
|
272
282
|
unsourcedCopyLines,
|
|
273
283
|
ideaSpec
|
|
274
284
|
};
|
|
275
|
-
//# sourceMappingURL=chunk-
|
|
285
|
+
//# sourceMappingURL=chunk-2GT76KEX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/creatives/make-model.ts"],"sourcesContent":["/**\n * The rules `baker creatives make` applies to turn an idea into a creative: which reference to\n * look for, which one fits, and what the creative records about the idea it carries. Pure.\n */\nimport { proofStrength } from \"@baker/api/ad-library\";\nimport { parse, parseDocument, Scalar, visit } from \"yaml\";\nimport { AD_SPEC_SCHEMA, type AdSpec, unfitReasons } from \"../../engine/scaffold/static-ad-spec.ts\";\nimport type { ViewerTemperature } from \"../../viewer-profile.ts\";\nimport type { PersonaEntry } from \"../canvas/viewer-check.ts\";\nimport type { FitAnswer, FitBet } from \"../winning-ads/fit.ts\";\nimport type { WinningAdsSearchArgs } from \"../winning-ads/search.ts\";\nimport { type EvidenceLevel, figuresIn, IDEA_VIDEO_FORMATS, type Idea, unsourcedClaims } from \"./ideas-model.ts\";\nimport type { ReferenceBrief } from \"./reference-brief.ts\";\nimport type { RankedFor } from \"./reference-rank.ts\";\n\nexport const REFERENCE_CANDIDATES = 6;\n\n/** Whether the idea is a video, built from beats, rather than a static from a reference. */\nexport function isVideoIdea(idea: Pick<Idea, \"format\">): boolean {\n return (IDEA_VIDEO_FORMATS as readonly string[]).includes(idea.format ?? \"\");\n}\n\n/** Who a reference was made for, by our viewer: a stranger's ad never leans on its own brand. */\nconst BY_TEMPERATURE: Record<ViewerTemperature, { audienceTemperature: string; excludeBrandReliant?: true }> = {\n cold: { audienceTemperature: \"0_cold\", excludeBrandReliant: true },\n warm: { audienceTemperature: \"1_warm_engaged,2_hot_visited\", excludeBrandReliant: true },\n hot: { audienceTemperature: \"3_customer\" },\n};\n\n/**\n * Where a reference is looked for: the company's market (`GB`), what it sells (\"rooftop solar\") and\n * who the ad is for (\"Bill-shocked homeowner\") and its broader industry (\"home energy\"), when known.\n */\nexport type ReferenceWhere = {\n country?: string;\n category?: string;\n audience?: string;\n /** Searches that widen from the ad, closest first: adjacent products, the same buyer, the same decision. */\n wider?: readonly string[];\n industry?: string;\n /** The kind of picture the idea shows, in the library's words (the brief's read of `shows`). */\n shows?: readonly string[];\n};\n\n/**\n * The library search for a static idea's reference: its container, made for our viewer, on what\n * the company sells (else the idea's message), in its market when given.\n */\nexport function referenceSearchFor(\n idea: Idea,\n temperature: ViewerTemperature,\n where: ReferenceWhere = {},\n): WinningAdsSearchArgs {\n return {\n query: where.category || idea.message,\n scope: \"followed-first\",\n platform: \"meta\",\n format: \"static\",\n formatPattern: idea.format,\n awareness: idea.awareness,\n ...BY_TEMPERATURE[temperature],\n ...(where.country ? { country: where.country } : {}),\n maxPerAdvertiser: 1,\n limit: REFERENCE_CANDIDATES,\n diverse: true,\n };\n}\n\n/**\n * The searches whose candidates are tried, best first. A proven ad of what the company sells comes\n * before the idea's container: its market, viewer and objections are ours, and its container is one\n * the thinking can keep or change. So: what the company sells, in its market (in the idea's\n * container for our viewer, loosened in turn, then any container), then anywhere; then ads made for\n * the same people, whatever they sell; then wider (an adjacent product, the same buyer buying\n * something else, the same kind of decision); then ads of the broader industry; then the message;\n * then the container's proven winners from any category, in the market and anywhere.\n * The library's judge scores an ad against the query: prod, Oct 2026, a customer's sentence about\n * one product matched no ad of another category and 13 of 15 ideas found nothing; dev, Oct 2026,\n * searched with the whole message, a UK solar installer's ads were checked against a crypto\n * exchange, a clinic and an English course, while the library held UK solar ads; and with the\n * container a filter, 7 of 10 companies found 0–2 ads of their own category.\n */\nexport function referenceSearchesFor(\n idea: Idea,\n temperature: ViewerTemperature,\n where: ReferenceWhere = {},\n): WinningAdsSearchArgs[] {\n const strict = referenceSearchFor(idea, temperature, where);\n const { awareness: _awareness, ...anyStage } = strict;\n const { audienceTemperature: _temperature, excludeBrandReliant: _reliant, ...viewerAny } = anyStage;\n const anyViewer = { ...viewerAny, scope: \"all\" as const };\n const { formatPattern: _pattern, ...anyContainer } = anyViewer;\n const { country: _country, ...anywhere } = anyViewer;\n const { country: _anyCountry, ...anyContainerAnywhere } = anyContainer;\n const { query: _query, ...winners } = anyStage;\n const { query: _anyQuery, country: _winnersCountry, ...winnersAnywhere } = anyViewer;\n const inMarket = (steps: WinningAdsSearchArgs[]) => (where.country ? steps : []);\n // What the idea shows, from any category: the picture that lands the message is found where it\n // won, and the ranking then asks whether it was made for our buyer.\n const shows = idea.shows?.trim();\n const { formatPattern: _shownPattern, ...anyCategory } = { ...anyStage, scope: \"all\" as const };\n const { country: _shownCountry, ...anyCategoryAnywhere } = anyCategory;\n const { country: _viewerCountry, ...anyViewerAnywhere } = anyViewer;\n const { formatPattern: _anyPattern, ...shownAnyViewer } = anyViewerAnywhere;\n const kinds = (where.shows ?? []).flatMap((q) => (q.trim() ? [{ ...anyCategoryAnywhere, query: q.trim() }] : []));\n const shown: WinningAdsSearchArgs[] = shows\n ? [\n ...inMarket([{ ...anyCategory, query: shows }]),\n ...kinds,\n { ...anyCategoryAnywhere, query: shows },\n { ...shownAnyViewer, query: shows },\n ...(idea.format ? [{ ...anyViewerAnywhere, query: shows }] : []),\n ]\n : [];\n const anyAd = (query: string | undefined) =>\n query?.trim()\n ? [...inMarket([{ ...anyContainer, query: query.trim() }]), { ...anyContainerAnywhere, query: query.trim() }]\n : [];\n // With what it shows searched first, the company's category is a short fallback: every search\n // runs at once, and the full ladder beside them ran a make out of its time (dev, Oct 2026).\n if (shows) {\n return [\n ...shown,\n ...(where.category ? [anyContainerAnywhere] : []),\n ...(where.audience?.trim() ? [{ ...anyContainerAnywhere, query: where.audience.trim() }] : []),\n { ...winnersAnywhere, sort: \"winner\" },\n ];\n }\n return [\n ...(where.country ? [strict, anyStage, anyContainer] : [strict, anyStage]),\n anywhere,\n anyContainerAnywhere,\n ...anyAd(where.audience),\n ...(where.wider ?? []).flatMap((q) => (q.trim() ? [{ ...anyContainerAnywhere, query: q.trim() }] : [])),\n ...anyAd(where.industry),\n ...(where.category ? [{ ...anyContainerAnywhere, query: idea.message }] : []),\n ...inMarket([{ ...winners, sort: \"winner\" }]),\n { ...winnersAnywhere, sort: \"winner\" },\n ];\n}\n\n/**\n * Where a reference is looked for, from the brief when the model read one (its market over the\n * notes' guess; every market when it says the ad runs in several), else from the notes. Pure.\n */\nexport function referenceWhereOf(brief: ReferenceBrief | null, fallback: ReferenceWhere): ReferenceWhere {\n if (!brief) return fallback;\n const country = brief.country === null ? undefined : (brief.country ?? fallback.country);\n const audience = brief.audience ?? fallback.audience;\n return {\n ...(country ? { country } : {}),\n category: brief.category,\n ...(brief.industry ? { industry: brief.industry } : {}),\n ...(audience ? { audience } : {}),\n ...(brief.wider.length ? { wider: brief.wider } : {}),\n ...(brief.shows?.length ? { shows: brief.shows } : {}),\n };\n}\n\n/** The ad being made, as candidates are ranked and picked for it: the brief's read, else the search's words. Pure. */\nexport function rankedForOf(\n brief: ReferenceBrief | null,\n where: ReferenceWhere,\n bet: Pick<FitBet, \"who\" | \"message\" | \"shows\">,\n): RankedFor {\n return {\n category: brief?.category ?? where.category ?? bet.message,\n ...(brief?.industry ? { industry: brief.industry } : {}),\n ...(brief?.buyer ? { buyer: brief.buyer } : {}),\n ...(brief?.humour ? { humour: brief.humour } : {}),\n ...(brief?.memes ? { memes: brief.memes } : {}),\n ...(brief?.memesWhy ? { memesWhy: brief.memesWhy } : {}),\n ...(brief?.avoid.length ? { avoid: brief.avoid } : {}),\n message: bet.message,\n who: bet.who,\n ...(bet.shows ? { shows: bet.shows } : {}),\n };\n}\n\n/** A name as the library and a person may both spell it: no accents, case or punctuation. Pure. */\nconst brandKey = (name: string) =>\n name\n .normalize(\"NFD\")\n .replace(/\\p{M}/gu, \"\")\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}]/gu, \"\");\n\n/** Whether an ad's advertiser is the company itself, by its brand names (three letters or more). Pure. */\nexport function isOwnBrand(advertiser: string | null | undefined, brands: readonly string[]): boolean {\n const page = brandKey(advertiser ?? \"\");\n return page !== \"\" && brands.some((b) => brandKey(b).length >= 3 && page.includes(brandKey(b)));\n}\n\ntype PoolCandidate = { ad_id?: string | null; advertiser_id?: string | null; winner_score?: number | null };\n\n/**\n * Every search's candidates in one list, the better search's first, one ad per brand (each fit\n * tried is another brand's move), the ads whose run barely proves them (`proofStrength` \"little\")\n * after the proven ones, at most `limit`. Pure.\n */\nexport function pooledCandidates<T extends PoolCandidate>(searches: readonly T[][], limit: number): T[] {\n const seen = new Set<string>();\n const pooled: T[] = [];\n for (const candidate of searches.flat()) {\n const brand = candidate.advertiser_id ? `brand:${candidate.advertiser_id}` : null;\n if (!candidate.ad_id || seen.has(candidate.ad_id) || (brand && seen.has(brand))) continue;\n seen.add(candidate.ad_id);\n if (brand) seen.add(brand);\n pooled.push(candidate);\n }\n const proven = (c: T) => proofStrength(c.winner_score) !== \"little\";\n return [...pooled.filter(proven), ...pooled.filter((c) => !proven(c))].slice(0, limit);\n}\n\n/** The proven ads, and their brands, the workspace's other creatives are already built on. */\nexport type TakenReferences = { adIds: ReadonlySet<string>; advertiserIds: ReadonlySet<string> };\n\n/**\n * The candidates no other creative is built on first (neither the ad nor its brand), then the\n * rest, each in its order: a batch of ideas is no longer built on one winning ad over and over,\n * and one already used is still built on when nothing else fits. Pure.\n */\nexport function freshReferencesFirst<T extends PoolCandidate>(candidates: readonly T[], taken: TakenReferences): T[] {\n return [\n ...candidates.filter((c) => !isTakenReference(c, taken)),\n ...candidates.filter((c) => isTakenReference(c, taken)),\n ];\n}\n\n/** Whether another creative is built on this ad or on another ad of its brand. Pure. */\nexport function isTakenReference(c: PoolCandidate, taken: TakenReferences): boolean {\n return (\n (c.ad_id != null && taken.adIds.has(c.ad_id)) ||\n (c.advertiser_id != null && taken.advertiserIds.has(c.advertiser_id))\n );\n}\n\n/** A reference fits when what it wins on is something we can supply, and our viewer would stop for it. */\nexport function fitsIdea(fit: Pick<FitAnswer, \"verdict\" | \"load_bearing\" | \"our_viewer\">): boolean {\n return fit.verdict !== \"reject\" && missingElements(fit).length === 0 && fit.our_viewer?.stops !== \"no\";\n}\n\n/** The load-bearing elements a reference wins on that we have nothing for. Pure. */\nexport function missingElements(fit: Pick<FitAnswer, \"load_bearing\">): string[] {\n return fit.load_bearing.filter((l) => l.have === \"missing\" && !l.ours?.trim()).map((l) => l.element);\n}\n\n/**\n * Why a checked reference was not built on, in one line the person can hear: what stops the scroll\n * or the proof that cannot be ours first, with the rule that forbids it; else that our viewer would\n * not stop for it; else the check's own note. Pure.\n */\nexport function whyUnfit(fit: Pick<FitAnswer, \"load_bearing\" | \"our_viewer\" | \"transfer_note\">): string {\n const reasons = unfitReasons(fit);\n if (reasons.length > 0) return reasons.join(\"; \");\n if (fit.our_viewer?.stops === \"no\") {\n return `our viewer would not stop for it${fit.our_viewer.why ? `: ${fit.our_viewer.why}` : \"\"}`;\n }\n return fit.transfer_note?.trim() || \"the check found it does not carry this ad\";\n}\n\nexport type DefinitionStrategyFields = {\n idea: string;\n message: string;\n evidence?: EvidenceLevel;\n angle: string;\n persona: string;\n awareness: string;\n hypothesis: string;\n};\n\n/** What a creative records about the idea it executes. */\nexport function definitionFieldsOf(idea: Idea, evidence: EvidenceLevel | \"explore\"): DefinitionStrategyFields {\n return {\n idea: idea.id,\n message: idea.message,\n ...(evidence !== \"explore\" ? { evidence } : {}),\n angle: idea.angle,\n persona: idea.who,\n awareness: idea.awareness,\n hypothesis: idea.why,\n };\n}\n\nconst FRONTMATTER = /^---\\r?\\n([\\s\\S]*?\\r?\\n)?---/;\n\n/** Whether a bare string reads back as the same text under YAML 1.1. */\nfunction readsAsText11(text: string): boolean {\n try {\n return parse(text, { version: \"1.1\" }) === text;\n } catch {\n return false;\n }\n}\n\n/** Set fields in a markdown file's frontmatter, keeping every other field and the body. */\nexport function setDefinitionFields(raw: string, fields: Record<string, unknown>): string {\n const match = raw.match(FRONTMATTER);\n if (!match) return raw;\n const doc = parseDocument(match[1] ?? \"\");\n if (doc.errors.length > 0) return raw;\n for (const [key, value] of Object.entries(fields)) {\n if (value === undefined) continue;\n const node = doc.createNode(value);\n // The site reads frontmatter as YAML 1.1, where a bare 2026-10-04 is a date, not text.\n visit(node, {\n Scalar(_, scalar) {\n if (typeof scalar.value === \"string\" && !readsAsText11(scalar.value)) {\n scalar.type = Scalar.QUOTE_DOUBLE;\n }\n },\n });\n doc.set(key, node);\n }\n return `---\\n${doc.toString()}---${raw.slice(match[0].length)}`;\n}\n\n/** The ad spec with the idea's message as the one thing it tells the viewer. */\nexport function setSpecMessage(specJson: string, message: string): string {\n const spec = JSON.parse(specJson) as Record<string, unknown>;\n return `${JSON.stringify({ ...spec, message }, null, 2)}\\n`;\n}\n\n/**\n * The ad spec made for the idea's persona: its title and segment from the Knowledge (\"The owner on\n * the move (Owner, 30–55, 1–10 staff)\"), else the idea's own words. The image prompt, the casting\n * check and the viewer check all read `viewer.who`; a reference-built spec held only the\n * scaffold's placeholder. The market and what the viewer knows are kept. Pure.\n */\nexport function setSpecViewer(specJson: string, idea: Pick<Idea, \"who\">, personas: readonly PersonaEntry[]): string {\n const spec = JSON.parse(specJson) as Record<string, unknown>;\n const viewer = (spec.viewer ?? {}) as Record<string, unknown>;\n return `${JSON.stringify({ ...spec, viewer: { ...viewer, who: personaWho(idea, personas) } }, null, 2)}\\n`;\n}\n\n/** Who an idea is for, in its persona's words (\"The owner on the move (Owner, 30–55)\"), else its own. Pure. */\nexport function personaWho(idea: Pick<Idea, \"who\">, personas: readonly PersonaEntry[]): string {\n const persona = personas.find((p) => p.slug === idea.who);\n if (persona?.title) return `${persona.title}${persona.segment ? ` (${persona.segment})` : \"\"}`;\n return persona?.segment ?? idea.who.replace(/[-_]/g, \" \");\n}\n\n/** The most words the audience search keeps: the library's judge reads a long query slowly. */\nconst AUDIENCE_QUERY_WORDS = 9;\n\n/**\n * The people the idea is for, as a library search: its persona's own words, cut short. Dev, Oct\n * 2026: \"homeowners worried about rising energy bills\" found twelve proven energy ads where\n * \"rooftop solar\" in the idea's container found one. Pure.\n */\nexport function audienceQuery(idea: Pick<Idea, \"who\">, personas: readonly PersonaEntry[]): string {\n return personaWho(idea, personas)\n .replace(/\\(/g, \" \")\n .replace(/\\)/g, \"\")\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, AUDIENCE_QUERY_WORDS)\n .join(\" \")\n .replace(/[\\s,;:.–—-]+$/, \"\");\n}\n\n/** The ad being made, as the fit judges a reference for it: its persona, message and the customers' words it stands on. Pure. */\nexport function fitBetOf(\n idea: Pick<Idea, \"who\" | \"message\" | \"awareness\" | \"angle\" | \"evidence\" | \"shows\">,\n personas: readonly PersonaEntry[],\n insights: readonly { id: string; quote: string }[],\n market?: string,\n): FitBet {\n const quotes = insights.filter((i) => idea.evidence.includes(i.id)).map((i) => i.quote);\n return {\n who: personaWho(idea, personas),\n message: idea.message,\n awareness: idea.awareness,\n angle: idea.angle,\n ...(idea.shows ? { shows: idea.shows } : {}),\n ...(quotes.length > 0 ? { quotes } : {}),\n ...(market ? { market } : {}),\n };\n}\n\n/**\n * The ad spec with the concept the reference's fit read (`conceptFromFit`): a build started before\n * the fit answered has none, or only the one the scaffold drafted from its describe, which names no\n * reference and nothing of what we have; without the fit's, the render never sees the reference at\n * the level that won. A concept a fit already seeded (it names its reference) stays. Pure.\n */\nexport function withFitConcept(specJson: string, seeded: Record<string, unknown>): string {\n const spec = JSON.parse(specJson) as Record<string, unknown>;\n const held = spec.concept as { reference_ad_id?: unknown } | undefined;\n if (held?.reference_ad_id) return specJson;\n return `${JSON.stringify({ ...spec, ...seeded }, null, 2)}\\n`;\n}\n\n/**\n * The copy lines the scaffold drafted that claim a figure the company never wrote: a draft written\n * beside a competitor's ad can carry the competitor's promise. `corpus` is what the company wrote.\n */\nexport function unsourcedCopyLines(specJson: string, corpus: string): string[] {\n const spec = JSON.parse(specJson) as { copy?: unknown };\n const figures = figuresIn(corpus);\n const lines = Array.isArray(spec.copy) ? spec.copy : [];\n return lines.flatMap((line) => {\n const text = typeof line === \"object\" && line !== null ? (line as { text?: unknown }).text : undefined;\n return typeof text === \"string\" && unsourcedClaims(text, figures).length > 0 ? [text] : [];\n });\n}\n\n/** Containers shown as a photograph; every other container is a designed graphic or a screen. */\nconst PHOTO_FORMATS = /photo|lifestyle|before_after|ugc|product|selfie|street/;\n\n/**\n * The ad spec an idea starts from when no proven ad fits it: the message and who it is for are\n * the idea's; the scene and the copy are placeholders the agent writes before anything renders\n * (`canvas run` refuses a placeholder). Pure.\n */\nexport function ideaSpec(idea: Idea, who: string): AdSpec {\n const container = idea.format ? `, as a ${idea.format.replace(/_/g, \" \")}` : \"\";\n const shows = idea.shows ? ` (${idea.shows})` : \"\";\n return {\n schema: AD_SPEC_SCHEMA,\n viewer: { who },\n message: idea.message,\n copy: [{ text: \"[TODO: the headline, in the customer's words]\", lettering: \"designed\", role: \"headline\" }],\n scene: {\n description: `[TODO: what the viewer sees first${shows}${container}, that shows: ${idea.message}]`,\n look: PHOTO_FORMATS.test(idea.format ?? idea.shows ?? \"\") ? \"photo\" : \"designed\",\n },\n colors: [],\n references: [],\n logo: true,\n third_party_brands: [],\n scene_text: [],\n mechanism: [],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,SAAS,OAAO,eAAe,QAAQ,aAAa;AAU7C,IAAM,uBAAuB;AAG7B,SAAS,YAAY,MAAqC;AAC/D,SAAQ,mBAAyC,SAAS,KAAK,UAAU,EAAE;AAC7E;AAGA,IAAM,iBAAyG;AAAA,EAC7G,MAAM,EAAE,qBAAqB,UAAU,qBAAqB,KAAK;AAAA,EACjE,MAAM,EAAE,qBAAqB,gC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,QAAQ,CAAC,SAAS;AAC7B,UAAM,OAAO,OAAO,SAAS,YAAY,SAAS,OAAQ,KAA4B,OAAO;AAC7F,WAAO,OAAO,SAAS,YAAY,gBAAgB,MAAM,OAAO,EAAE,SAAS,IAAI,CAAC,IAAI,IAAI,CAAC;AAAA,EAC3F,CAAC;AACH;AAGA,IAAM,gBAAgB;AAOf,SAAS,SAAS,MAAY,KAAqB;AACxD,QAAM,YAAY,KAAK,SAAS,UAAU,KAAK,OAAO,QAAQ,MAAM,GAAG,CAAC,KAAK;AAC7E,QAAM,QAAQ,KAAK,QAAQ,KAAK,KAAK,KAAK,MAAM;AAChD,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ,EAAE,IAAI;AAAA,IACd,SAAS,KAAK;AAAA,IACd,MAAM,CAAC,EAAE,MAAM,iDAAiD,WAAW,YAAY,MAAM,WAAW,CAAC;AAAA,IACzG,OAAO;AAAA,MACL,aAAa,oCAAoC,KAAK,GAAG,SAAS,iBAAiB,KAAK,OAAO;AAAA,MAC/F,MAAM,cAAc,KAAK,KAAK,UAAU,KAAK,SAAS,EAAE,IAAI,UAAU;AAAA,IACxE;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,YAAY,CAAC;AAAA,IACb,MAAM;AAAA,IACN,oBAAoB,CAAC;AAAA,IACrB,YAAY,CAAC;AAAA,IACb,WAAW,CAAC;AAAA,EACd;AACF;","names":[]}
|
|
@@ -305,13 +305,16 @@ function figuresIn(text2) {
|
|
|
305
305
|
function normalize(value) {
|
|
306
306
|
return value.toLowerCase().replace(/\s+/g, " ").trim();
|
|
307
307
|
}
|
|
308
|
+
function pictureOf(idea) {
|
|
309
|
+
return idea.format ?? normalize(idea.shows ?? "");
|
|
310
|
+
}
|
|
308
311
|
function sentencesOf(message) {
|
|
309
312
|
return message.split(/[.!?]+(?:\s|$)/).filter((s) => s.trim().length > 0).length;
|
|
310
313
|
}
|
|
311
314
|
var SAME_WORDS = (a, b) => normalize(a) === normalize(b);
|
|
312
315
|
function repeatedFailure(idea, failed, sameMessage) {
|
|
313
316
|
const lost = failed.find(
|
|
314
|
-
(f) => f.id !== idea.id && (sameMessage(f.message, idea.message) || f.angle === idea.angle && f
|
|
317
|
+
(f) => f.id !== idea.id && (sameMessage(f.message, idea.message) || f.angle === idea.angle && pictureOf(f) === pictureOf(idea))
|
|
315
318
|
);
|
|
316
319
|
return lost ? [`says what "${lost.id}" said, and that idea failed in the account: change the message, not just the picture`] : [];
|
|
317
320
|
}
|
|
@@ -461,7 +464,7 @@ function duplicatesOf(ideas, insights) {
|
|
|
461
464
|
const seenMessages = /* @__PURE__ */ new Map();
|
|
462
465
|
const duplicateOf = /* @__PURE__ */ new Map();
|
|
463
466
|
for (const idea of order) {
|
|
464
|
-
const pair = `${idea.angle}\xD7${
|
|
467
|
+
const pair = `${idea.angle}\xD7${pictureOf(idea)}`;
|
|
465
468
|
const message = normalize(idea.message);
|
|
466
469
|
const earlier = seenPairs.get(pair) ?? seenMessages.get(message);
|
|
467
470
|
if (earlier) duplicateOf.set(idea.id, earlier);
|
|
@@ -621,4 +624,4 @@ export {
|
|
|
621
624
|
readLearnedRules,
|
|
622
625
|
declaredRules
|
|
623
626
|
};
|
|
624
|
-
//# sourceMappingURL=chunk-
|
|
627
|
+
//# sourceMappingURL=chunk-3VCHJN2B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engine/creative-rules/schema.ts","../src/engine/copy-tells/rule-tells.ts","../src/commands/creatives/ideas-model.ts","../src/engine/creative-rules/read.ts"],"sourcesContent":["/**\n * A creative rule: a standing must, never or prefer about every ad a company makes. Declared ones\n * are the brand's own (BRAND.md, read by `brand-doc.ts`); learned ones are what a person taught in a\n * chat, one file each in `src/content/creative-rules/<slug>.md`, saved only after they said yes.\n * Read when a call runs, never copied into an ad's own files.\n */\nimport { z } from \"zod\";\n\nexport const RULE_STRENGTHS = [\"never\", \"must\", \"prefer\"] as const;\nexport type RuleStrength = (typeof RULE_STRENGTHS)[number];\n\n/** What of the ad a rule is about, and so which check holds it. */\nexport const RULE_APPLIES = [\"copy\", \"picture\", \"cast\", \"logo\", \"voice\", \"sound\", \"subtitles\", \"any\"] as const;\nexport type RuleApplies = (typeof RULE_APPLIES)[number];\n\nexport const RULE_KINDS = [\"static\", \"video\"] as const;\n\n/** Where a rule holds; absent parts hold everywhere. */\nexport type RuleScope = {\n kinds?: Array<(typeof RULE_KINDS)[number]>;\n /** Product slugs (`src/content/products/<slug>.md`) a business unit's rule is about. */\n products?: string[];\n platforms?: string[];\n /** The language its phrases are in (\"es\"): its wording checks hold only in ads in that language. */\n language?: string;\n};\n\n/**\n * The part of a rule code can decide on the ad's words: phrases it bans (`forbid`, except where they\n * sit inside an `allow`), phrases every ad must say (`require`), and that only real people may appear.\n */\nexport type RuleCheck = {\n forbid?: string[];\n require?: string[];\n allow?: string[];\n people?: \"real\";\n};\n\nexport const RULE_SOURCE_KINDS = [\"feedback\", \"user\", \"brand-import\", \"brand\"] as const;\n\nexport type RuleSource = {\n kind: (typeof RULE_SOURCE_KINDS)[number];\n feedbackId?: string;\n runId?: string;\n slug?: string;\n /** The person's own words the rule came from. */\n quote?: string;\n /** When it was taught (YYYY-MM-DD). */\n date?: string;\n};\n\nexport type CreativeRule = {\n /** The file's slug for a learned rule; `brand-<hash>` for one BRAND.md states. */\n id: string;\n origin: \"learned\" | \"declared\";\n strength: RuleStrength;\n applies: RuleApplies;\n scope: RuleScope;\n check?: RuleCheck;\n /** The rule, in the words it was given in. */\n text: string;\n why?: string;\n source: RuleSource;\n status: \"active\" | \"retired\";\n retiredBy?: string;\n};\n\nconst phrase = z.string().trim().min(1).max(120);\n\n/** A list of phrases, each trimmed, the empty and malformed ones dropped. */\nexport const Phrases = z\n .array(z.unknown())\n .transform((list) => list.flatMap((p) => (phrase.safeParse(p).success ? [String(p).trim()] : [])));\n","/**\n * The company's wording rules, checked on an ad's words without a model: a phrase a rule bans\n * (except inside a phrase it allows) and a phrase every ad must say. Whole phrases only, read the\n * way a person reads them: accents, case and spacing folded (\"100 % online\" is \"100% Online\"), ß as\n * ss. A rule whose phrases differ only in case is about spelling, and keeps case (\"ZentIA\", never\n * \"Zentia\"). A rule in one language holds only in ads in that language. Never and must rules only:\n * a prefer is the reviewers' to weigh. Pure and total.\n */\nimport type { CreativeRule } from \"../creative-rules/schema.ts\";\n\nexport type RuleTell = {\n rule: string;\n strength: CreativeRule[\"strength\"];\n /** A phrase the rule bans was found, or none of the lines says one it requires. */\n kind: \"forbidden\" | \"missing\";\n phrase: string;\n /** The line it was found in (a forbidden phrase only). */\n line?: string;\n /** The rule's words. */\n text: string;\n /** The person's own words, when they taught it. */\n quote?: string;\n};\n\n/** Marks that separate words rather than say anything: never part of a phrase unless it is only marks. */\nconst SOFT = new Set([\n \".\",\n \",\",\n \";\",\n \":\",\n \"!\",\n \"?\",\n \"¡\",\n \"¿\",\n '\"',\n \"'\",\n \"“\",\n \"”\",\n \"‘\",\n \"’\",\n \"«\",\n \"»\",\n \"(\",\n \")\",\n \"[\",\n \"]\",\n \"{\",\n \"}\",\n \"…\",\n \"-\",\n \"/\",\n \"*\",\n \"_\",\n]);\n\n/** Accents off, ß as ss, and case folded unless the rule is about case. Pure. */\nfunction fold(text: string, keepCase: boolean): string {\n const plain = text.normalize(\"NFKD\").replace(/\\p{M}/gu, \"\").replace(/ß/g, \"ss\").replace(/ẞ/g, \"SS\");\n return keepCase ? plain : plain.toLowerCase();\n}\n\n/** The words and marks of a text, as phrases are matched on; the separating marks only when `marks`. Pure. */\nfunction tokens(text: string, keepCase: boolean, marks = false): string[] {\n const all = fold(text, keepCase).match(/[\\p{L}\\p{N}]+|[^\\s\\p{L}\\p{N}]/gu) ?? [];\n return marks ? all : all.filter((t) => !SOFT.has(t));\n}\n\n/** Whether a phrase is only separating marks (\"!\", \"¿\"): then it is matched among the marks of a line. Pure. */\nfunction onlyMarks(phrase: string, keepCase: boolean): boolean {\n return tokens(phrase, keepCase).length === 0 && tokens(phrase, keepCase, true).length > 0;\n}\n\n/** Where `phrase` starts in `words`, every place. Pure. */\nfunction positions(words: readonly string[], phrase: readonly string[]): number[] {\n if (phrase.length === 0) return [];\n const at: number[] = [];\n for (let i = 0; i + phrase.length <= words.length; i++) {\n if (phrase.every((w, j) => words[i + j] === w)) at.push(i);\n }\n return at;\n}\n\n/** A rule is about case when two of its phrases are the same word but for case. Pure. */\nfunction aboutCase(check: NonNullable<CreativeRule[\"check\"]>): boolean {\n const phrases = [...(check.forbid ?? []), ...(check.allow ?? []), ...(check.require ?? [])];\n return phrases.some((a, i) =>\n phrases.some((b, j) => i !== j && a !== b && fold(a, false) === fold(b, false) && fold(a, true) !== fold(b, true)),\n );\n}\n\n/** Whether a rule in one language holds for an ad in `language`: the same primary tag, or a rule in none. Pure. */\nfunction sameLanguage(rule: CreativeRule, language: string | undefined): boolean {\n const ruleLanguage = rule.scope.language;\n if (!ruleLanguage) return true;\n if (!language) return false;\n const primary = (tag: string) => tag.toLowerCase().split(/[-_]/)[0];\n return primary(ruleLanguage) === primary(language);\n}\n\n/** The first phrase of `forbid` a line says outside every `allow`, or null. Pure. */\nfunction forbiddenIn(line: string, check: NonNullable<CreativeRule[\"check\"]>, keepCase: boolean): string | null {\n for (const banned of check.forbid ?? []) {\n const marks = onlyMarks(banned, keepCase);\n const words = tokens(line, keepCase, marks);\n const allowed = (check.allow ?? []).flatMap((a) => {\n const allow = tokens(a, keepCase, marks);\n return positions(words, allow).map((start) => [start, start + allow.length] as const);\n });\n const phrase = tokens(banned, keepCase, marks);\n const free = positions(words, phrase).some(\n (start) => !allowed.some(([from, to]) => start >= from && start + phrase.length <= to),\n );\n if (free) return banned;\n }\n return null;\n}\n\n/** What one rule finds in the lines: each line saying a phrase it bans, each phrase it requires none says. Pure. */\nfunction tellsOf(rule: CreativeRule, lines: readonly string[]): RuleTell[] {\n const check = rule.check;\n if (!check) return [];\n const keepCase = aboutCase(check);\n const base = {\n rule: rule.id,\n strength: rule.strength,\n text: rule.text,\n ...(rule.source.quote ? { quote: rule.source.quote } : {}),\n };\n const forbidden = lines.flatMap((line) => {\n const phrase = forbiddenIn(line, check, keepCase);\n return phrase ? [{ ...base, kind: \"forbidden\" as const, phrase, line }] : [];\n });\n const missing = (check.require ?? []).flatMap((required) => {\n const marks = onlyMarks(required, keepCase);\n const phrase = tokens(required, keepCase, marks);\n const said = lines.some((line) => positions(tokens(line, keepCase, marks), phrase).length > 0);\n return said ? [] : [{ ...base, kind: \"missing\" as const, phrase: required }];\n });\n return [...forbidden, ...missing];\n}\n\n/** Every wording rule the lines break, the line it is broken in first. Pure. */\nexport function ruleTells(\n lines: readonly string[],\n rules: readonly CreativeRule[],\n language: string | undefined,\n): RuleTell[] {\n return rules\n .filter((rule) => rule.strength !== \"prefer\" && sameLanguage(rule, language))\n .flatMap((rule) => tellsOf(rule, lines));\n}\n","/**\n * Ideas and the customer truths they stand on.\n *\n * An idea (src/creatives/_ideas/<id>.md) is one bet: who it is for, the one thing it says, the\n * customer evidence behind it and how it says it. An insight (src/content/insights/<id>.md) is\n * one customer truth, a quote with its source. `checkIdeas` is the judgment the agent used to\n * carry in prose: is each idea backed by something a customer said, does it claim only what the\n * Knowledge holds, is it a different ad from the others, does it fill a gap. Pure.\n */\nimport { staticFormatPatternSchema } from \"@baker/api\";\nimport { AD_PLATFORMS } from \"@baker/canvas-contract\";\nimport { parse as parseYaml, YAMLParseError } from \"yaml\";\nimport { ruleTells } from \"../../engine/copy-tells/rule-tells.ts\";\nimport type { CreativeRule } from \"../../engine/creative-rules/schema.ts\";\n\n/** How an idea persuades, in the ads library's own angle vocabulary, so ours and theirs compare. */\nexport const IDEA_ANGLES = [\n \"pain_relief\",\n \"aspiration\",\n \"status\",\n \"fear\",\n \"FOMO\",\n \"identity\",\n \"contrarian\",\n \"education\",\n \"novelty\",\n \"authority\",\n \"community\",\n \"transformation\",\n \"convenience\",\n \"save_money\",\n \"save_time\",\n \"save_effort\",\n \"named_enemy\",\n \"objection_crusher\",\n \"villain_democratization\",\n \"commiseration\",\n \"recognition_mirror\",\n \"flipped_idiom\",\n] as const;\n\n/** Video formats an idea may take; every other format is a static container from the library. */\nexport const IDEA_VIDEO_FORMATS = [\n \"video_ugc\",\n \"video_founder\",\n \"video_testimonial\",\n \"video_demo\",\n \"video_screen_recording\",\n \"video_explainer\",\n \"video_motion_graphics\",\n] as const;\n\nexport const IDEA_FORMATS: readonly string[] = [...staticFormatPatternSchema.options, ...IDEA_VIDEO_FORMATS];\n\nexport const AWARENESS_STAGES = [\"unaware\", \"problem_aware\", \"solution_aware\", \"product_aware\", \"most_aware\"] as const;\nexport type AwarenessStage = (typeof AWARENESS_STAGES)[number];\n\nexport const EVIDENCE_LEVELS = [\"observed\", \"interpreted\", \"hypothesized\", \"generated\"] as const;\nexport type EvidenceLevel = (typeof EVIDENCE_LEVELS)[number];\n\nexport const IDEA_STATUSES = [\"idea\", \"built\", \"testing\", \"winner\", \"failed\", \"inconclusive\", \"retired\"] as const;\nexport type IdeaStatus = (typeof IDEA_STATUSES)[number];\n\nexport type Insight = {\n id: string;\n type: string;\n quote: string;\n source: string;\n status: EvidenceLevel;\n sourceKind?: string;\n force?: string;\n persona?: string;\n /** Who said it, as the research wrote it (\"A 5★ Trustpilot review by Lena Fischer.\"). */\n author?: string;\n};\n\nexport type Idea = {\n id: string;\n who: string;\n message: string;\n evidence: string[];\n awareness: AwarenessStage;\n angle: string;\n /**\n * What the scroller sees in the first second that makes the message land (\"before/after split:\n * a tangle of 16 platform logos, then one API key\"). The proven ad is searched by it, in any category.\n */\n shows?: string;\n /** The container: a video style (built from beats), or a static one the idea insists on. Absent: the proven ad's. */\n format?: string;\n job: \"opener\" | \"closer\";\n why: string;\n status: IdeaStatus;\n /** Where its ads run, main platform first (`AD_PLATFORMS`): the sizes they are made in. Absent: not said yet. */\n platforms?: string[];\n};\n\nconst FRONTMATTER = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---/;\n\n/** A markdown file's frontmatter as an object, or null when it has none or it does not parse. */\nexport function frontmatterOf(markdown: string): Record<string, unknown> | null {\n const block = FRONTMATTER.exec(markdown)?.[1];\n if (block === undefined) return null;\n try {\n const parsed: unknown = parseYaml(block);\n return parsed !== null && typeof parsed === \"object\" && !Array.isArray(parsed)\n ? (parsed as Record<string, unknown>)\n : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Why a file's frontmatter does not parse, naming the line, or null when it parses (or has none).\n * Dev, Oct 2026: an unquoted `why: \"a minefield\" with quotes` read as every field missing. Pure.\n */\nexport function frontmatterError(markdown: string): string | null {\n const block = FRONTMATTER.exec(markdown)?.[1];\n if (block === undefined) return null;\n try {\n parseYaml(block);\n return null;\n } catch (e) {\n const line = e instanceof YAMLParseError ? e.linePos?.[0]?.line : undefined;\n const at = line ? ` at line ${line} (\\`${block.split(/\\r?\\n/)[line - 1]?.trim() ?? \"\"}\\`)` : \"\";\n return `the frontmatter is not valid YAML${at}: put each text value wholly in double quotes, with any quote inside it as \\\\\" or as single quotes`;\n }\n}\n\nfunction text(value: unknown): string | undefined {\n if (typeof value === \"string\") return value.trim() || undefined;\n if (typeof value === \"number\") return String(value);\n return undefined;\n}\n\nfunction oneOf<T extends string>(values: readonly T[], value: unknown): T | undefined {\n return typeof value === \"string\" && (values as readonly string[]).includes(value) ? (value as T) : undefined;\n}\n\n/** A source a reader can open: a link, or a library entry (`testimonials:t1`). */\nconst CHECKABLE_SOURCE = /^(?:https?:\\/\\/\\S+|[a-z_]+:[\\w-]+)$/i;\n\n/**\n * How strong an insight really is: one filed as observed is read as interpreted when its source\n * cannot be checked. Audited live Oct 2026: article lines, sourced \"an article (referenced in …)\",\n * filed as what customers said. A quote that is a statistic about people rather than someone's\n * words is the other half of that audit, and a reading of the words: `ideas-judgments.ts`.\n */\nfunction evidenceStatus(stated: EvidenceLevel, source: string): EvidenceLevel {\n if (stated !== \"observed\") return stated;\n return CHECKABLE_SOURCE.test(source) ? \"observed\" : \"interpreted\";\n}\n\n/** One customer truth, or null when it carries no quote or source to stand on. */\nexport function parseInsight(id: string, markdown: string): Insight | null {\n const fm = frontmatterOf(markdown);\n const quote = text(fm?.quote);\n const source = text(fm?.source);\n if (!fm || !quote || !source) return null;\n const force = text(fm.force);\n const persona = text(fm.persona);\n const sourceKind = text(fm.sourceKind);\n const author = markdown\n .replace(/^---[\\s\\S]*?\\n---/, \"\")\n .match(/\\bby ([\\p{Lu}][\\p{L}'’-]*\\.?(?: [\\p{Lu}][\\p{L}'’-]*\\.?)?)/u)?.[1]\n // The sentence's full stop, never an initial's (\"Marta G.\").\n ?.replace(/(\\p{L}{2,})\\.$/u, \"$1\");\n return {\n id,\n type: text(fm.type) ?? \"other\",\n quote,\n source,\n status: evidenceStatus(oneOf(EVIDENCE_LEVELS, fm.status) ?? \"observed\", source),\n ...(sourceKind ? { sourceKind } : {}),\n ...(force ? { force } : {}),\n ...(persona ? { persona } : {}),\n ...(author ? { author } : {}),\n };\n}\n\nfunction evidenceList(value: unknown): string[] {\n if (Array.isArray(value)) return value.flatMap((e) => (text(e) ? [String(text(e))] : []));\n const single = text(value);\n return single ? [single] : [];\n}\n\ntype IdeaFields = {\n who?: string;\n message?: string;\n why?: string;\n angle?: string;\n shows?: string;\n format?: string;\n awareness?: AwarenessStage;\n /** The awareness as written, to quote back when it is not a stage. */\n awarenessWritten?: string;\n /** The platforms as written; absent when the idea names none (never a problem). */\n platforms?: string[];\n};\n\nfunction fieldProblems(f: IdeaFields): string[] {\n const problems: string[] = [];\n if (!f.who) problems.push(\"who is missing: the persona it is for\");\n if (!f.message)\n problems.push(\n \"message is missing: the one promise a stranger should get, what is offered and what changes for them\",\n );\n if (!f.why) problems.push(\"why is missing: the brief finding it answers\");\n if (!f.awareness) {\n const written = f.awarenessWritten ? `\"${f.awarenessWritten}\" ` : \"\";\n problems.push(`awareness ${written}must be one of ${AWARENESS_STAGES.join(\", \")}`);\n }\n if (!(f.angle && (IDEA_ANGLES as readonly string[]).includes(f.angle)))\n problems.push(`angle ${f.angle ? `\"${f.angle}\" ` : \"\"}must be one of ${IDEA_ANGLES.join(\", \")}`);\n if (f.format && !IDEA_FORMATS.includes(f.format))\n problems.push(`format \"${f.format}\" must be one of ${IDEA_FORMATS.join(\", \")}`);\n if (!f.format && !f.shows)\n problems.push(\n \"shows is missing: what the scroller sees in the first second that makes the message land (a before/after, a reaction, the product doing it, a real review, the pain itself); the proven ad is searched by it\",\n );\n return [...problems, ...platformProblems(f.platforms)];\n}\n\n/** A platform the catalog does not know, named with the ones it does; none named is no problem. */\nfunction platformProblems(platforms: readonly string[] | undefined): string[] {\n const unknown = (platforms ?? []).filter((p) => !(AD_PLATFORMS as readonly string[]).includes(p));\n return unknown.length > 0\n ? [`platforms ${unknown.map((p) => `\"${p}\"`).join(\", \")} must be among ${AD_PLATFORMS.join(\", \")}`]\n : [];\n}\n\n/** The platforms an idea names, as written (a single name read as a list of one). */\nfunction platformList(value: unknown): string[] | undefined {\n const list = (Array.isArray(value) ? value : value === undefined || value === null ? [] : [value])\n .map((v) => text(v))\n .filter((v): v is string => v !== undefined);\n return list.length > 0 ? list : undefined;\n}\n\n/** One idea file, or every problem that keeps it from being one. */\nexport function parseIdea(id: string, markdown: string): { idea?: Idea; problems: string[] } {\n const unparsable = frontmatterError(markdown);\n if (unparsable) return { problems: [unparsable] };\n const fm = frontmatterOf(markdown) ?? {};\n const f: IdeaFields = {\n who: text(fm.who),\n message: text(fm.message),\n why: text(fm.why),\n angle: text(fm.angle),\n shows: text(fm.shows),\n format: text(fm.format),\n awareness: oneOf(AWARENESS_STAGES, fm.awareness),\n awarenessWritten: text(fm.awareness),\n platforms: platformList(fm.platforms),\n };\n const problems = fieldProblems(f);\n const { who, message, why, angle, shows, format, awareness } = f;\n if (problems.length > 0 || !who || !message || !why || !awareness || !angle) return { problems };\n return {\n idea: {\n id,\n who,\n message,\n evidence: evidenceList(fm.evidence),\n awareness,\n angle,\n ...(shows ? { shows } : {}),\n ...(format ? { format } : {}),\n job: fm.job === \"closer\" ? \"closer\" : \"opener\",\n why,\n status: oneOf(IDEA_STATUSES, fm.status) ?? \"idea\",\n ...(f.platforms ? { platforms: f.platforms } : {}),\n },\n problems,\n };\n}\n\nexport type IdeaCheck = {\n id: string;\n status: IdeaStatus;\n message: string;\n /** The strongest evidence behind it; `explore` when no insight backs it. */\n evidence: EvidenceLevel | \"explore\";\n /** The customer's own words it stands on, when it has some. */\n quote?: string;\n awareness: AwarenessStage;\n angle: string;\n /** What the scroller sees first, when the idea says. */\n shows?: string;\n /** The container, when the idea names one; absent: the proven ad's. */\n format?: string;\n /** Where its ads run, main platform first; absent when the idea names nowhere. */\n platforms?: string[];\n /** Blocks building it until fixed. */\n problems: string[];\n /** Worth fixing; never blocks. */\n warnings: string[];\n /** What it adds that the live ads do not have. */\n gaps: string[];\n score: number;\n};\n\nexport type CheckIdeasInput = {\n ideas: readonly Idea[];\n insights: readonly Insight[];\n /** Everything the company's documents say (COMPANY.md, the Knowledge): the claims an ad may make. */\n knowledge: string;\n /** Persona entry ids in the Knowledge; empty when there are none to check against. */\n personas: readonly string[];\n /** Awareness stages the company's live or built ads already speak to. */\n coveredAwareness: readonly string[];\n /** How many live or built ideas close (`job: closer`). */\n closersLive: number;\n /** Whether two messages say the same thing (`ideas-judgments.ts`); the same words, without it. */\n sameMessage?: SameMessage;\n /** The company's rules for its ads: a message that breaks a wording rule is not an idea to build. */\n rules?: readonly CreativeRule[];\n /** The language the ideas' messages are in (the company's market's), for the wording rules. */\n language?: string;\n};\n\nconst EVIDENCE_WEIGHT: Record<EvidenceLevel | \"explore\", number> = {\n observed: 3,\n interpreted: 2,\n hypothesized: 1,\n generated: 0,\n explore: 0,\n};\n\nconst LIVE_STATUSES: readonly IdeaStatus[] = [\"built\", \"testing\", \"winner\"];\n\n/** Numbers, percentages and prices a message states: each must be found in what the company wrote. */\nfunction claimsOf(message: string): string[] {\n return [...message.matchAll(/\\d[\\d.,]*\\s?(?:%|€|\\$|£|x\\b|k\\b)?/gi)].map((m) => m[0].trim());\n}\n\n/** A figure as written anywhere, separators dropped: \"4.990 €\", \"4990€\" and \"4,990\" are one number. */\nfunction figureOf(claim: string): string {\n return claim.replace(/[^\\d]/g, \"\");\n}\n\n/** Every whole number a text states, so \"4\" is never found inside \"4.990\". Pure. */\nexport function figuresIn(text: string): Set<string> {\n return new Set([...text.matchAll(/\\d(?:[\\d.,]*\\d)?/g)].map((m) => figureOf(m[0])));\n}\n\nfunction normalize(value: string): string {\n return value.toLowerCase().replace(/\\s+/g, \" \").trim();\n}\n\n/** What an idea's picture is: the container it insists on, else what it shows. */\nfunction pictureOf(idea: Idea): string {\n return idea.format ?? normalize(idea.shows ?? \"\");\n}\n\nfunction sentencesOf(message: string): number {\n return message.split(/[.!?]+(?:\\s|$)/).filter((s) => s.trim().length > 0).length;\n}\n\ntype CheckContext = {\n insights: ReadonlyMap<string, Insight>;\n corpusFigures: ReadonlySet<string>;\n covered: ReadonlySet<string>;\n duplicateOf: ReadonlyMap<string, string>;\n personas: readonly string[];\n closersLive: number;\n failed: readonly Idea[];\n sameMessage: SameMessage;\n rules: readonly CreativeRule[];\n language: string | undefined;\n};\n\n/** Whether two ad messages say the same thing, however reworded. */\nexport type SameMessage = (a: string, b: string) => boolean;\n\n/** Without a reading of the words, only the same message written the same way is one. Pure. */\nexport const SAME_WORDS: SameMessage = (a, b) => normalize(a) === normalize(b);\n\n/** A failed idea this one repeats: the same message (reworded or not), or the same angle in the same picture. */\nfunction repeatedFailure(idea: Idea, failed: readonly Idea[], sameMessage: SameMessage): string[] {\n const lost = failed.find(\n (f) =>\n f.id !== idea.id &&\n (sameMessage(f.message, idea.message) || (f.angle === idea.angle && pictureOf(f) === pictureOf(idea))),\n );\n return lost\n ? [`says what \"${lost.id}\" said, and that idea failed in the account: change the message, not just the picture`]\n : [];\n}\n\n/** The insight on file whose id and quote share the most words with `id`, an id written from memory. */\nfunction likelyMeant(id: string, insights: ReadonlyMap<string, Insight>): string | undefined {\n const words = (text: string) =>\n new Set(\n text\n .toLowerCase()\n .split(/[^\\p{L}\\p{N}]+/u)\n .filter((w) => w.length >= 3),\n );\n const wanted = words(id);\n let best: { id: string; shared: number } | undefined;\n for (const insight of insights.values()) {\n const said = words(`${insight.id} ${insight.quote}`);\n const shared = [...wanted].filter((w) => said.has(w)).length;\n if (shared > 0 && shared > (best?.shared ?? 0)) best = { id: insight.id, shared };\n }\n return best?.id;\n}\n\nfunction backingOf(idea: Idea, insights: ReadonlyMap<string, Insight>, problems: string[]) {\n const backing = idea.evidence.flatMap((id) => {\n const insight = insights.get(id);\n if (!insight) {\n const meant = likelyMeant(id, insights);\n problems.push(\n `evidence \"${id}\" is not in src/content/insights/: ${meant ? `did you mean \"${meant}\"? ` : \"\"}name an insight on file by its id, or leave it out`,\n );\n }\n return insight ? [insight] : [];\n });\n return [...backing].sort((a, b) => EVIDENCE_WEIGHT[b.status] - EVIDENCE_WEIGHT[a.status])[0];\n}\n\n/** The figures a text claims that nothing the company wrote holds. Pure. */\nexport function unsourcedClaims(text: string, corpusFigures: ReadonlySet<string>): string[] {\n return claimsOf(text).filter((claim) => {\n const figure = figureOf(claim);\n return figure !== \"\" && !corpusFigures.has(figure);\n });\n}\n\n/**\n * Why an insight that states a figure cannot stand behind it as our claim, in words the agent can act\n * on. Review, Oct 2026: a figure held by an insight read as interpreted only for its unlinked source\n * was said to be in no quote at all, and the agent searched for what it already had. Pure.\n */\nfunction whyNotBacking(insight: Insight): string {\n const named = `the insight \"${insight.id}\"`;\n if (fromMarket(insight))\n return `${named}, what someone in the market said, not our customer: it is never our claim; drop it`;\n if (insight.status === \"hypothesized\" || insight.status === \"generated\")\n return `${named}, a ${insight.status} reading, not a customer's words: source it or drop it`;\n if (!CHECKABLE_SOURCE.test(insight.source))\n return `${named}, which cites no link a reader can open (its source: \"${insight.source}\"): give it its link, or drop the figure`;\n return `${named}, a statistic about people rather than a customer's words: it cannot stand behind our claim; drop it`;\n}\n\nfunction claimProblems(message: string, ctx: Pick<CheckContext, \"corpusFigures\" | \"insights\">): string[] {\n return unsourcedClaims(message, ctx.corpusFigures).map((claim) => {\n const figure = figureOf(claim);\n const holder = [...ctx.insights.values()].find((insight) => figuresIn(insight.quote).has(figure));\n return holder\n ? `\"${claim}\" is in ${whyNotBacking(holder)}`\n : `\"${claim}\" is in no customer quote, COMPANY.md or Knowledge entry: source it or drop it`;\n });\n}\n\n/** Where people in the market speak, as opposed to our own customers (reviews, testimonials, calls…). */\nexport const MARKET_SOURCES: readonly string[] = [\"reddit\", \"forum\", \"web\"];\nconst TESTIMONIAL_FORMATS = [\"review_screenshot\", \"testimonial_quote\", \"video_testimonial\"];\n\nfunction fromMarket(insight: Insight | undefined): boolean {\n return insight?.sourceKind !== undefined && MARKET_SOURCES.includes(insight.sourceKind);\n}\n\n/** An insight whose figures may stand behind our claim: our own customer's words, as written. */\nexport function sourcesClaims(insight: Insight): boolean {\n return insight.status === \"observed\" && !fromMarket(insight);\n}\n\n/** A cited result someone in the market reported, which an ad could pass off as ours. */\nfunction borrowedProof(idea: Idea, insights: ReadonlyMap<string, Insight>): string | undefined {\n return idea.evidence.find((id) => {\n const insight = insights.get(id);\n return fromMarket(insight) && insight?.type === \"proof\";\n });\n}\n\n/** A review or testimonial format with no quote from our own customers: it could only be a fake review. */\nfunction fakeReviewProblem(idea: Idea, insights: ReadonlyMap<string, Insight>): string[] {\n if (!idea.format || !TESTIMONIAL_FORMATS.includes(idea.format)) return [];\n const cited = idea.evidence.flatMap((id) => insights.get(id) ?? []);\n if (cited.length === 0 || !cited.every(fromMarket)) return [];\n return [\n `${idea.format} needs a quote from our own customer (a review, testimonial, call or survey); every one cited was said by someone in the market. Pick another format, or cite our own customer`,\n ];\n}\n\nfunction warningsOf(\n idea: Idea,\n evidence: EvidenceLevel | \"explore\",\n personas: readonly string[],\n insights: ReadonlyMap<string, Insight>,\n): string[] {\n const warnings: string[] = [];\n const video = (IDEA_VIDEO_FORMATS as readonly string[]).includes(idea.format ?? \"\");\n if (idea.status === \"idea\" && !video && !idea.shows)\n warnings.push(\n \"say what it shows (`shows`): what the scroller sees in the first second that lands the message; the proven ad is searched by it, and without it by what the company sells\",\n );\n const borrowed = borrowedProof(idea, insights);\n if (borrowed) {\n warnings.push(\n `\"${borrowed}\" was said by someone in the market, not a customer of ours: use their words for the problem, never show it as our review, testimonial or result`,\n );\n }\n if (sentencesOf(idea.message) > 1 || idea.message.split(/\\s+/).length > 25) {\n warnings.push(\n 'the message says more than one thing: keep one promise that still names what is offered (\"a free roof survey that shows your real saving\", never a slogan like \"the numbers, explained\"), the rest goes to the ad text',\n );\n }\n if (personas.length > 0 && !personas.includes(idea.who)) {\n warnings.push(`who \"${idea.who}\" is not a persona in the Knowledge (${personas.join(\", \")})`);\n }\n if (evidence === \"explore\") {\n warnings.push(\"no customer evidence: an explore bet. `baker research customers` may find some\");\n }\n return warnings;\n}\n\nfunction checkOne(idea: Idea, ctx: CheckContext): IdeaCheck {\n const problems: string[] = [];\n const best = backingOf(idea, ctx.insights, problems);\n const evidence = best?.status ?? \"explore\";\n problems.push(\n ...claimProblems(idea.message, ctx),\n ...fakeReviewProblem(idea, ctx.insights),\n // The message is one line of the ad: a phrase a rule requires may sit in another.\n ...ruleTells([idea.message], ctx.rules, ctx.language)\n .filter((t) => t.kind === \"forbidden\")\n .map((t) => `The message says \"${t.phrase}\": ${t.rule} (${t.strength}) — ${t.text}`),\n );\n const duplicate = ctx.duplicateOf.get(idea.id);\n if (duplicate) {\n problems.push(\n `same angle and the same picture (format or what it shows), or the same message, as \"${duplicate}\": to the platform it is the same ad. Change the angle or what it shows`,\n );\n }\n const gaps: string[] = [];\n if (!ctx.covered.has(idea.awareness)) gaps.push(`no live ad speaks to ${idea.awareness} people`);\n if (idea.job === \"closer\" && ctx.closersLive === 0) gaps.push(\"no live ad closes warm people\");\n return {\n id: idea.id,\n status: idea.status,\n message: idea.message,\n evidence,\n ...(best ? { quote: best.quote } : {}),\n awareness: idea.awareness,\n angle: idea.angle,\n ...(idea.shows ? { shows: idea.shows } : {}),\n ...(idea.format ? { format: idea.format } : {}),\n ...(idea.platforms ? { platforms: idea.platforms } : {}),\n problems,\n warnings: [\n ...warningsOf(idea, evidence, ctx.personas, ctx.insights),\n ...repeatedFailure(idea, ctx.failed, ctx.sameMessage),\n ],\n gaps,\n score: EVIDENCE_WEIGHT[evidence] + gaps.length - (problems.length > 0 ? 10 : 0),\n };\n}\n\n/** Which idea repeats an earlier one: a built idea, then the better-evidenced, then the first written keeps it. */\nfunction duplicatesOf(ideas: readonly Idea[], insights: ReadonlyMap<string, Insight>): Map<string, string> {\n const active = ideas.filter((i) => i.status !== \"retired\" && i.status !== \"failed\");\n const strength = (idea: Idea) =>\n Math.max(0, ...idea.evidence.map((id) => EVIDENCE_WEIGHT[insights.get(id)?.status ?? \"explore\"]));\n const position = new Map(ideas.map((idea, index) => [idea.id, index]));\n const order = [...active].sort(\n (a, b) =>\n Number(LIVE_STATUSES.includes(b.status)) - Number(LIVE_STATUSES.includes(a.status)) ||\n strength(b) - strength(a) ||\n (position.get(a.id) ?? 0) - (position.get(b.id) ?? 0),\n );\n const seenPairs = new Map<string, string>();\n const seenMessages = new Map<string, string>();\n const duplicateOf = new Map<string, string>();\n for (const idea of order) {\n const pair = `${idea.angle}×${pictureOf(idea)}`;\n const message = normalize(idea.message);\n const earlier = seenPairs.get(pair) ?? seenMessages.get(message);\n if (earlier) duplicateOf.set(idea.id, earlier);\n if (!seenPairs.has(pair)) seenPairs.set(pair, idea.id);\n if (!seenMessages.has(message)) seenMessages.set(message, idea.id);\n }\n return duplicateOf;\n}\n\n/**\n * Check and rank every idea. Ideas still to build come first, best first: the strongest customer\n * evidence, then a gap the live ads leave; anything with a problem sinks. Built ideas follow.\n */\nexport function checkIdeas(input: CheckIdeasInput): IdeaCheck[] {\n const insights = new Map(input.insights.map((insight) => [insight.id, insight]));\n // What our own customers said, word for word, can source a claim; a stranger's number or a reading never can.\n const ownQuotes = input.insights.filter(sourcesClaims).map((i) => i.quote);\n const corpusFigures = figuresIn(`${input.knowledge}\\n${ownQuotes.join(\"\\n\")}`);\n const covered = new Set(input.coveredAwareness);\n const duplicateOf = duplicatesOf(input.ideas, insights);\n const checks = input.ideas.map((idea) =>\n checkOne(idea, {\n insights,\n corpusFigures,\n covered,\n duplicateOf,\n personas: input.personas,\n closersLive: input.closersLive,\n failed: input.ideas.filter((i) => i.status === \"failed\"),\n sameMessage: input.sameMessage ?? SAME_WORDS,\n rules: input.rules ?? [],\n language: input.language,\n }),\n );\n\n const toBuild = (c: IdeaCheck) => c.status === \"idea\";\n return checks.sort(\n (a, b) => Number(toBuild(b)) - Number(toBuild(a)) || b.score - a.score || a.id.localeCompare(b.id),\n );\n}\n","/**\n * Where a company's creative rules come from: the brand's own (BRAND.md, through its reading) and\n * the ones a person taught in a chat (`src/content/creative-rules/<slug>.md`, one per file). Each is\n * read as it stands when a call runs; nothing is copied into an ad's files.\n */\nimport { createHash } from \"node:crypto\";\nimport { readdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { z } from \"zod\";\nimport { frontmatterOf } from \"../../commands/creatives/ideas-model.ts\";\nimport type { BrandRule } from \"../brand/brand-rules.ts\";\nimport {\n type CreativeRule,\n Phrases,\n RULE_APPLIES,\n RULE_KINDS,\n RULE_SOURCE_KINDS,\n RULE_STRENGTHS,\n type RuleCheck,\n} from \"./schema.ts\";\n\n/** Where the learned rules live in a workspace. */\nexport const RULES_DIR = path.join(\"src\", \"content\", \"creative-rules\");\n\nconst optionalText = z.string().trim().min(1).max(2000).optional().catch(undefined);\nconst optionalPhrases = Phrases.optional().catch(undefined);\nconst dateText = z\n .union([z.string(), z.date().transform((d) => d.toISOString().slice(0, 10))])\n .pipe(z.string().trim().min(1))\n .optional()\n .catch(undefined);\n\nconst Frontmatter = z.object({\n strength: z.enum(RULE_STRENGTHS).catch(\"must\"),\n applies: z.enum(RULE_APPLIES).catch(\"any\"),\n scope: z\n .object({\n kinds: z.array(z.enum(RULE_KINDS)).optional().catch(undefined),\n products: optionalPhrases,\n platforms: optionalPhrases,\n language: z.string().trim().min(2).max(10).optional().catch(undefined),\n })\n .catch({}),\n check: z\n .object({\n forbid: optionalPhrases,\n require: optionalPhrases,\n allow: optionalPhrases,\n people: z.literal(\"real\").optional().catch(undefined),\n })\n .optional()\n .catch(undefined),\n source: z\n .object({\n kind: z.enum(RULE_SOURCE_KINDS).catch(\"user\"),\n feedbackId: optionalText,\n runId: optionalText,\n slug: optionalText,\n quote: optionalText,\n date: dateText,\n })\n .catch({ kind: \"user\" }),\n status: z.enum([\"active\", \"retired\"]).catch(\"active\"),\n retiredBy: optionalText,\n});\n\n/** An object with its undefined and empty-list entries left out. Pure. */\nfunction defined<T extends object>(value: T): T {\n return Object.fromEntries(\n Object.entries(value).filter(([, v]) => v !== undefined && !(Array.isArray(v) && v.length === 0)),\n ) as T;\n}\n\n/** The rule's words (the body's first paragraph) and its why (a `Why:` paragraph). Pure. */\nfunction bodyOf(markdown: string): { text?: string; why?: string } {\n const body = markdown.replace(/^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n?/, \"\").trim();\n const paragraphs = body\n .split(/\\r?\\n\\s*\\r?\\n/)\n .map((p) => p.trim())\n .filter(Boolean);\n const why = paragraphs.find((p) => /^(?:why|por qué|porque)\\s*:/i.test(p));\n const text = paragraphs.find((p) => p !== why && !p.startsWith(\"#\"));\n return { ...(text ? { text } : {}), ...(why ? { why: why.replace(/^[^:]+:\\s*/, \"\") } : {}) };\n}\n\n/** A rule file as a rule, read leniently (a hand edit still teaches it); null without words. Pure. */\nexport function parseRuleFile(id: string, markdown: string): CreativeRule | null {\n const { text, why } = bodyOf(markdown);\n if (!text) return null;\n const fm = Frontmatter.parse(frontmatterOf(markdown) ?? {});\n const check = fm.check ? defined<RuleCheck>(fm.check) : undefined;\n return {\n id,\n origin: \"learned\",\n strength: fm.strength,\n applies: fm.applies,\n scope: defined(fm.scope),\n ...(check && Object.keys(check).length > 0 ? { check } : {}),\n text,\n ...(why ? { why } : {}),\n source: defined(fm.source),\n status: fm.status,\n ...(fm.retiredBy ? { retiredBy: fm.retiredBy } : {}),\n };\n}\n\n/** Every rule file in the workspace, by its slug; none when there is no folder. */\nexport async function readLearnedRules(root: string): Promise<CreativeRule[]> {\n const dir = path.join(root, RULES_DIR);\n const files = (await readdir(dir).catch(() => [] as string[])).filter((f) => f.endsWith(\".md\")).sort();\n const rules = await Promise.all(\n files.map(async (file) =>\n parseRuleFile(file.replace(/\\.md$/, \"\"), await readFile(path.join(dir, file), \"utf8\").catch(() => \"\")),\n ),\n );\n return rules.filter((r): r is CreativeRule => r !== null);\n}\n\n/** A declared rule's id: its words decide it, so the same rule keeps it across readings. Pure. */\nconst declaredId = (text: string) => `brand-${createHash(\"sha256\").update(text.trim()).digest(\"hex\").slice(0, 8)}`;\n\n/**\n * A ban the rule's own words show as both right and wrong, no allowed phrase telling them apart:\n * \"'£640 a year, at 24p a unit', never '£640 a year'\" bans a bare figure, not the words, so code\n * cannot check it (live, Oct 2026: read as banning \"£640 a year\", which the right form says too).\n */\nfunction shownBothWays(text: string, phrase: string, allow: readonly string[] | undefined): boolean {\n const fold = (s: string) => s.normalize(\"NFKD\").replace(/\\p{M}/gu, \"\").toLowerCase();\n const said = fold(text).split(fold(phrase)).length - 1;\n return said > 1 && !(allow ?? []).some((a) => fold(a).includes(fold(phrase)));\n}\n\n/** A bare word of one or two letters (\"IA\", \"DS\"): an acronym a brand bans reads as an ordinary word too. */\nconst BARE_SHORT_WORD = /^\\p{L}{1,2}$/u;\n\n/**\n * The rules the brand's documents state, as creative rules. Code holds only the words a brand bans,\n * never the ones it says to use: a brand document's \"must\" depends on the piece (prod, Oct 2026: its\n * taglines and CTAs fired on 28 of 66 approved ads), and the reviewers weigh those. Pure.\n */\nexport function declaredRules(rules: readonly BrandRule[]): CreativeRule[] {\n return rules.map(({ text, strength, applies, forbid, allow }) => {\n const checked = forbid?.filter((p) => !BARE_SHORT_WORD.test(p.trim()) && !shownBothWays(text, p, allow));\n const check = defined<RuleCheck>({ forbid: checked, ...(checked?.length ? { allow } : {}) });\n return {\n id: declaredId(text),\n origin: \"declared\",\n strength,\n applies,\n scope: {},\n ...(Object.keys(check).length > 0 ? { check } : {}),\n text,\n source: { kind: \"brand\" },\n status: \"active\",\n };\n });\n}\n"],"mappings":";;;;;;;;AAMA,SAAS,SAAS;AAEX,IAAM,iBAAiB,CAAC,SAAS,QAAQ,QAAQ;AAIjD,IAAM,eAAe,CAAC,QAAQ,WAAW,QAAQ,QAAQ,SAAS,SAAS,aAAa,KAAK;AAG7F,IAAM,aAAa,CAAC,UAAU,OAAO;AAuBrC,IAAM,oBAAoB,CAAC,YAAY,QAAQ,gBAAgB,OAAO;AA6B7E,IAAM,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAGxC,IAAM,UAAU,EACpB,MAAM,EAAE,QAAQ,CAAC,EACjB,UAAU,CAAC,SAAS,KAAK,QAAQ,CAAC,MAAO,OAAO,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAE,CAAC;;;AC/CnG,IAAM,OAAO,oBAAI,IAAI;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGD,SAAS,KAAKA,OAAc,UAA2B;AACrD,QAAM,QAAQA,MAAK,UAAU,MAAM,EAAE,QAAQ,WAAC,UAAM,IAAE,GAAE,EAAE,EAAE,QAAQ,MAAM,IAAI,EAAE,QAAQ,MAAM,IAAI;AAClG,SAAO,WAAW,QAAQ,MAAM,YAAY;AAC9C;AAGA,SAAS,OAAOA,OAA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,SAAgB,OAA+C;AAClG,QAAMC,QAAO,CAAC,MAAc,EAAE,UAAU,MAAM,EAAE,QAAQ,WAAC,UAAM,IAAE,GAAE,EAAE,EAAE,YAAY;AACnF,QAAM,OAAOA,MAAKF,KAAI,EAAE,MAAME,MAAKD,OAAM,CAAC,EAAE,SAAS;AACrD,SAAO,OAAO,KAAK,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,MAAMC,MAAK,CAAC,EAAE,SAASA,MAAKD,OAAM,CAAC,CAAC;AAC9E;AAGA,IAAM,kBAAkB,WAAC,iBAAa,GAAC;AAOhC,SAAS,cAAc,OAA6C;AACzE,SAAO,MAAM,IAAI,CAAC,EAAE,MAAAD,OAAM,UAAU,SAAS,QAAQ,MAAM,MAAM;AAC/D,UAAM,UAAU,QAAQ,OAAO,CAAC,MAAM,CAAC,gBAAgB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,cAAcA,OAAM,GAAG,KAAK,CAAC;AACvG,UAAM,QAAQ,QAAmB,EAAE,QAAQ,SAAS,GAAI,SAAS,SAAS,EAAE,MAAM,IAAI,CAAC,EAAG,CAAC;AAC3F,WAAO;AAAA,MACL,IAAI,WAAWA,KAAI;AAAA,MACnB,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA,OAAO,CAAC;AAAA,MACR,GAAI,OAAO,KAAK,KAAK,EAAE,SAAS,IAAI,EAAE,MAAM,IAAI,CAAC;AAAA,MACjD,MAAAA;AAAA,MACA,QAAQ,EAAE,MAAM,QAAQ;AAAA,MACxB,QAAQ;AAAA,IACV;AAAA,EACF,CAAC;AACH;","names":["text","phrase","text","z","z","text","phrase","fold"]}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
nodeParamsPreview
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-P5ENZXC2.js";
|
|
4
4
|
import {
|
|
5
5
|
creativeSlugFromCanvasPath
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WY5H3XYC.js";
|
|
7
7
|
import {
|
|
8
8
|
parseDefinitionDelivery,
|
|
9
9
|
parseDefinitionSeriesPlace,
|
|
10
10
|
parseDefinitionSourceFields,
|
|
11
11
|
parseDefinitionStrategyFields,
|
|
12
12
|
prepareCanvas
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-5VJK7NMF.js";
|
|
14
14
|
import {
|
|
15
15
|
BackendClient
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-YSB26POP.js";
|
|
17
17
|
import {
|
|
18
18
|
nodeDependencies
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-TFJW5CXD.js";
|
|
20
20
|
import {
|
|
21
21
|
requireCredentialsFromEnv
|
|
22
22
|
} from "./chunk-2FSEESJU.js";
|
|
@@ -221,4 +221,4 @@ export {
|
|
|
221
221
|
resolveCanvasPath,
|
|
222
222
|
syncDefinitionCommand
|
|
223
223
|
};
|
|
224
|
-
//# sourceMappingURL=chunk-
|
|
224
|
+
//# sourceMappingURL=chunk-4C55EB4J.js.map
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readInsights
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MP5IMGKF.js";
|
|
4
4
|
import {
|
|
5
5
|
heldRules,
|
|
6
6
|
readAdWords,
|
|
7
7
|
ruleGate
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-I5XXOMMR.js";
|
|
9
9
|
import {
|
|
10
10
|
avatarRelation,
|
|
11
11
|
castCompany
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-CN4YK7IU.js";
|
|
13
13
|
import {
|
|
14
14
|
readAvatars
|
|
15
15
|
} from "./chunk-LCW3U4EA.js";
|
|
16
16
|
import {
|
|
17
17
|
frontmatterOf,
|
|
18
18
|
sourcesClaims
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-3VCHJN2B.js";
|
|
20
20
|
import {
|
|
21
21
|
GENERIC_FAMILIES,
|
|
22
22
|
resolveBrandFaces
|
|
@@ -98,7 +98,7 @@ import {
|
|
|
98
98
|
staticRenderNodes,
|
|
99
99
|
trimmedRenderBand,
|
|
100
100
|
wordCount
|
|
101
|
-
} from "./chunk-
|
|
101
|
+
} from "./chunk-TFJW5CXD.js";
|
|
102
102
|
import {
|
|
103
103
|
blockingArea
|
|
104
104
|
} from "./chunk-XLJVJ5TK.js";
|
|
@@ -2636,7 +2636,7 @@ async function readNamedTypefaces(root = ".", opts = {}) {
|
|
|
2636
2636
|
}
|
|
2637
2637
|
var MARK_FILE = /isotype|isologo|symbol|logomark|brandmark|(^|[-_ ])(mark|icon|avatar)([-_ .]|$)/i;
|
|
2638
2638
|
var VARIANT_WORDS = new Set(
|
|
2639
|
-
"logo logos logotype logotipo lockup wordmark isotype isotipo isologo symbol logomark brandmark mark icon avatar favicon brand primary secondary main default full horizontal vertical stacked square round circle alt outline transparent light dark white black mono inverse inverted negative positive negativo positivo reverse reversed color colour on blanco negro negra claro clara oscuro oscura rgb cmyk small large sm md lg".split(" ")
|
|
2639
|
+
"logo logos logotype logotipo lockup wordmark isotype isotipo isologo symbol logomark brandmark mark icon avatar favicon brand primary secondary main default full horizontal vertical stacked square round circle alt outline transparent light dark white black mono inverse inverted negative positive negativo positivo reverse reversed color colour on blanco negro negra claro clara oscuro oscura rgb cmyk small large sm md lg red blue green yellow orange purple violet pink grey gray navy teal cyan magenta brown gold silver coral rojo roja azul verde amarillo amarilla naranja morado morada rosa gris dorado dorada plateado plateada".split(" ")
|
|
2640
2640
|
);
|
|
2641
2641
|
function artworkOwner(file, slug) {
|
|
2642
2642
|
const rest = path.basename(file).replace(/\.[a-z0-9]+$/i, "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().split(/[^a-z0-9]+/).filter((w) => w && !VARIANT_WORDS.has(w) && !/^\d+(x|px|w|h)?$/.test(w)).join("");
|
|
@@ -2770,11 +2770,12 @@ function nativeCanvas(canvas, spec, opts) {
|
|
|
2770
2770
|
const kept = nodesOf3(canvas).filter(
|
|
2771
2771
|
(n) => n.tags?.role === STATIC_AD_ROLE || n.id === "original" || n.id === "font_headline"
|
|
2772
2772
|
);
|
|
2773
|
-
const
|
|
2773
|
+
const wired = logosWired(canvas, opts);
|
|
2774
|
+
const logos = wired.map((where, i) => ({
|
|
2774
2775
|
id: logoId(i),
|
|
2775
2776
|
type: "ingest",
|
|
2776
2777
|
params: { ...where, expect: "image" },
|
|
2777
|
-
...i === 0 ? { tags: { role: BRAND_LOGO_ROLE } } : {}
|
|
2778
|
+
...i === 0 ? { tags: { role: BRAND_LOGO_ROLE, wired: wired.map(placeOf) } } : {}
|
|
2778
2779
|
}));
|
|
2779
2780
|
const mark = opts.mark ? [
|
|
2780
2781
|
{
|
|
@@ -2843,12 +2844,22 @@ function placeOf(where) {
|
|
|
2843
2844
|
function logosWired(canvas, opts) {
|
|
2844
2845
|
const own = opts.logos.map((file) => locate(file, opts));
|
|
2845
2846
|
const ownPlaces = new Set(own.map(placeOf));
|
|
2846
|
-
const
|
|
2847
|
+
const ingests = nodesOf3(canvas).filter(
|
|
2848
|
+
(n) => n.type === "ingest" && typeof n.id === "string" && /^brand_logo(_\d+)?$/.test(n.id)
|
|
2849
|
+
);
|
|
2850
|
+
const present = ingests.flatMap((n) => {
|
|
2847
2851
|
const p = n.params;
|
|
2848
|
-
|
|
2849
|
-
if (
|
|
2852
|
+
if (p?.source === "url" && typeof p.url === "string") return [locate(p.url, opts)];
|
|
2853
|
+
if (p?.source === "path" && typeof p.path === "string") return [locate(p.path, opts)];
|
|
2854
|
+
return [];
|
|
2855
|
+
});
|
|
2856
|
+
const lastWired = ingests.map((n) => n.tags?.wired).find(Array.isArray);
|
|
2857
|
+
const byHand = lastWired !== void 0 && (lastWired.length !== present.length || present.some((where, i) => placeOf(where) !== lastWired[i]));
|
|
2858
|
+
if (!byHand) return own;
|
|
2859
|
+
const chosen = present.filter((where) => {
|
|
2860
|
+
if (!ownPlaces.has(placeOf(where))) return false;
|
|
2850
2861
|
ownPlaces.delete(placeOf(where));
|
|
2851
|
-
return
|
|
2862
|
+
return true;
|
|
2852
2863
|
});
|
|
2853
2864
|
return chosen.length > 0 ? chosen : own;
|
|
2854
2865
|
}
|
|
@@ -8925,4 +8936,4 @@ export {
|
|
|
8925
8936
|
prepareCanvas,
|
|
8926
8937
|
exitOnPrepareError
|
|
8927
8938
|
};
|
|
8928
|
-
//# sourceMappingURL=chunk-
|
|
8939
|
+
//# sourceMappingURL=chunk-5VJK7NMF.js.map
|