@koda-sl/baker-cli 0.482.0 → 0.483.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 (164) hide show
  1. package/README.md +1 -1
  2. package/dist/{animate-3LV3LHXQ.js → animate-SVEPM267.js} +4 -4
  3. package/dist/{brand-CINQG3JG.js → brand-LAIIXZBL.js} +2 -2
  4. package/dist/{brief-WAQ2V6Q4.js → brief-7PICJ4CO.js} +13 -13
  5. package/dist/{canvas-A4XKEBN7.js → canvas-YS3ONCCX.js} +13 -13
  6. package/dist/{catalog-SJBGNNY4.js → catalog-RS4F5YK3.js} +8 -8
  7. package/dist/{check-GCZ2ZBKH.js → check-5RW2MX7V.js} +9 -9
  8. package/dist/{chunk-XSGO44OV.js → chunk-27DJRM3F.js} +4 -4
  9. package/dist/{chunk-WMVTIKET.js → chunk-3PXC2OXT.js} +2 -2
  10. package/dist/{chunk-U2452GLO.js → chunk-4AMIHNNP.js} +11 -6
  11. package/dist/chunk-4AMIHNNP.js.map +1 -0
  12. package/dist/{chunk-5YKC2WWG.js → chunk-4S4WDXJR.js} +6 -6
  13. package/dist/{chunk-GQ6JS5MR.js → chunk-4VB7F422.js} +56 -11
  14. package/dist/{chunk-GQ6JS5MR.js.map → chunk-4VB7F422.js.map} +1 -1
  15. package/dist/{chunk-ELL2IQMF.js → chunk-62JQQUAU.js} +12 -11
  16. package/dist/chunk-62JQQUAU.js.map +1 -0
  17. package/dist/{chunk-2DHHL4PU.js → chunk-66WEOQV5.js} +3 -3
  18. package/dist/{chunk-5RCCESDX.js → chunk-AXDKLXCG.js} +120 -41
  19. package/dist/chunk-AXDKLXCG.js.map +1 -0
  20. package/dist/{chunk-6KK26F2T.js → chunk-BTY4LZBG.js} +2 -2
  21. package/dist/{chunk-Q7YZL7PG.js → chunk-CS5JF52J.js} +2 -2
  22. package/dist/{chunk-5NS4CNF6.js → chunk-E2RFM6R2.js} +5 -5
  23. package/dist/{chunk-BSEB55E6.js → chunk-EOY6BK4C.js} +2 -2
  24. package/dist/{chunk-MMVLRUMK.js → chunk-G2LGMWNG.js} +27 -12
  25. package/dist/chunk-G2LGMWNG.js.map +1 -0
  26. package/dist/{chunk-ZBV5IV5T.js → chunk-IKCP5NCE.js} +2 -2
  27. package/dist/{chunk-RTWRNG3E.js → chunk-IN6AW5P3.js} +18 -8
  28. package/dist/{chunk-RTWRNG3E.js.map → chunk-IN6AW5P3.js.map} +1 -1
  29. package/dist/{chunk-DF22CTXE.js → chunk-IX2QLW6G.js} +2 -2
  30. package/dist/{chunk-65N4ZPQD.js → chunk-JAC6JVCI.js} +2 -2
  31. package/dist/{chunk-V6PXHQSI.js → chunk-JWSEPW7F.js} +2 -2
  32. package/dist/{chunk-AS5VL32C.js → chunk-JYALBYN7.js} +2 -2
  33. package/dist/{chunk-R2TAVQGZ.js → chunk-K2JTERIO.js} +2 -2
  34. package/dist/{chunk-3S5YZWB7.js → chunk-KDWH2JKT.js} +10 -7
  35. package/dist/chunk-KDWH2JKT.js.map +1 -0
  36. package/dist/{chunk-T6ATGN7Y.js → chunk-MCJ5I5LR.js} +1 -1
  37. package/dist/chunk-MCJ5I5LR.js.map +1 -0
  38. package/dist/{chunk-U4W4LULB.js → chunk-MGIOV72F.js} +7 -7
  39. package/dist/{chunk-ORQKMXHA.js → chunk-MZPS46OR.js} +2 -2
  40. package/dist/{chunk-RDCYPWQZ.js → chunk-NEOUY3Q7.js} +34 -9
  41. package/dist/chunk-NEOUY3Q7.js.map +1 -0
  42. package/dist/{chunk-K2Z3KGOH.js → chunk-NPMAATZG.js} +2 -2
  43. package/dist/{chunk-2K3NCVDI.js → chunk-OKJVBGMQ.js} +31 -19
  44. package/dist/{chunk-2K3NCVDI.js.map → chunk-OKJVBGMQ.js.map} +1 -1
  45. package/dist/{chunk-PQTY22FR.js → chunk-PZPSCYN3.js} +9 -8
  46. package/dist/chunk-PZPSCYN3.js.map +1 -0
  47. package/dist/{chunk-KQDAFZKR.js → chunk-Q4WWS3UQ.js} +2 -2
  48. package/dist/{chunk-A2FKWRKO.js → chunk-R3N4AIKS.js} +6 -6
  49. package/dist/{chunk-DCTEL4KG.js → chunk-RVXMK4X2.js} +3 -3
  50. package/dist/{chunk-LD4CHA7U.js → chunk-UKL7GWEH.js} +2 -2
  51. package/dist/{chunk-4VWTIT5C.js → chunk-UWXDNVS5.js} +2 -2
  52. package/dist/{chunk-U6IWRZQF.js → chunk-VNNCYWNN.js} +3 -3
  53. package/dist/{chunk-7U3V64YT.js → chunk-WKLQFSV6.js} +4 -4
  54. package/dist/{chunk-WD5BQBVY.js → chunk-Z5SOZUUB.js} +3 -3
  55. package/dist/{chunk-AQ5WISEG.js → chunk-ZCQVKDHV.js} +2 -2
  56. package/dist/{chunk-RCSOG2DV.js → chunk-ZINMEMOB.js} +5 -5
  57. package/dist/cli.js +7 -7
  58. package/dist/{creatives-U2M4F3D5.js → creatives-NK5HOXSF.js} +10 -10
  59. package/dist/{critique-43OVWKN7.js → critique-EDMP5P5R.js} +16 -16
  60. package/dist/{critique-JVKJEBAC.js → critique-N5OL42C6.js} +5 -5
  61. package/dist/{customers-P4N4NXLJ.js → customers-TLAHWJY6.js} +4 -4
  62. package/dist/engine/index.d.ts +1 -0
  63. package/dist/engine/index.js +7 -7
  64. package/dist/{feedback-3GU3PAEI.js → feedback-OCN3XNKF.js} +19 -19
  65. package/dist/{feedback-record-PIJDOJW3.js → feedback-record-Z66AXZ57.js} +20 -20
  66. package/dist/{fit-TVQ7RK52.js → fit-PMSNW2PF.js} +11 -11
  67. package/dist/{fonts-BMUNDGOZ.js → fonts-I434ILTG.js} +7 -7
  68. package/dist/{generate-4HWNFAH3.js → generate-OMXBFGGR.js} +3 -3
  69. package/dist/{ideas-UTSCGCT6.js → ideas-K6FQVDUA.js} +8 -8
  70. package/dist/{landing-AJO2BPC2.js → landing-EJGYTI5W.js} +2 -2
  71. package/dist/{learn-RGO5KDHS.js → learn-66SKYR36.js} +6 -6
  72. package/dist/{make-IHJROEKG.js → make-ZYEFMAR6.js} +51 -37
  73. package/dist/make-ZYEFMAR6.js.map +1 -0
  74. package/dist/{models-2DQ5NBMT.js → models-2XRYXSRA.js} +2 -2
  75. package/dist/{rerun-R3DNEV5U.js → rerun-DZKHTK66.js} +24 -24
  76. package/dist/{research-MBAPL35Y.js → research-L2DH5P22.js} +2 -2
  77. package/dist/{rules-SZIY67QF.js → rules-TPW37OVS.js} +8 -8
  78. package/dist/{rules-add-KTLHU3YD.js → rules-add-HTL6IFQJ.js} +8 -8
  79. package/dist/{run-QYIUO4NB.js → run-EID2OD4U.js} +24 -24
  80. package/dist/{scaffold-ad-NIVJSO73.js → scaffold-ad-SQZMHTRA.js} +24 -24
  81. package/dist/{scaffold-static-ad-QX2NUXFR.js → scaffold-static-ad-L2JCW5LF.js} +30 -30
  82. package/dist/{scaffold-video-NXBM54K3.js → scaffold-video-2WLFALNV.js} +21 -21
  83. package/dist/{select-Q4S4CPKV.js → select-POYNXE2L.js} +18 -18
  84. package/dist/{set-prompt-3MVZW3L6.js → set-prompt-2OXPI4ZF.js} +17 -17
  85. package/dist/{stale-NT2JRQHY.js → stale-6HL4ELJW.js} +17 -17
  86. package/dist/{studio-YB5WXQYC.js → studio-MARZ22J2.js} +4 -4
  87. package/dist/{sync-definition-6XPX6VJU.js → sync-definition-VVNXDNDC.js} +20 -20
  88. package/dist/{translate-27DIFMBU.js → translate-ACGKNKQP.js} +21 -21
  89. package/dist/{validate-AYPLNS7A.js → validate-SUW24MMI.js} +20 -20
  90. package/dist/{viewer-check-TSH3SAYJ.js → viewer-check-7S2EB32L.js} +10 -10
  91. package/dist/{winning-ads-SGBI3WHK.js → winning-ads-T4MOKDYT.js} +2 -2
  92. package/package.json +1 -1
  93. package/dist/chunk-3S5YZWB7.js.map +0 -1
  94. package/dist/chunk-5RCCESDX.js.map +0 -1
  95. package/dist/chunk-ELL2IQMF.js.map +0 -1
  96. package/dist/chunk-MMVLRUMK.js.map +0 -1
  97. package/dist/chunk-PQTY22FR.js.map +0 -1
  98. package/dist/chunk-RDCYPWQZ.js.map +0 -1
  99. package/dist/chunk-T6ATGN7Y.js.map +0 -1
  100. package/dist/chunk-U2452GLO.js.map +0 -1
  101. package/dist/make-IHJROEKG.js.map +0 -1
  102. /package/dist/{animate-3LV3LHXQ.js.map → animate-SVEPM267.js.map} +0 -0
  103. /package/dist/{brand-CINQG3JG.js.map → brand-LAIIXZBL.js.map} +0 -0
  104. /package/dist/{brief-WAQ2V6Q4.js.map → brief-7PICJ4CO.js.map} +0 -0
  105. /package/dist/{canvas-A4XKEBN7.js.map → canvas-YS3ONCCX.js.map} +0 -0
  106. /package/dist/{catalog-SJBGNNY4.js.map → catalog-RS4F5YK3.js.map} +0 -0
  107. /package/dist/{check-GCZ2ZBKH.js.map → check-5RW2MX7V.js.map} +0 -0
  108. /package/dist/{chunk-XSGO44OV.js.map → chunk-27DJRM3F.js.map} +0 -0
  109. /package/dist/{chunk-WMVTIKET.js.map → chunk-3PXC2OXT.js.map} +0 -0
  110. /package/dist/{chunk-5YKC2WWG.js.map → chunk-4S4WDXJR.js.map} +0 -0
  111. /package/dist/{chunk-2DHHL4PU.js.map → chunk-66WEOQV5.js.map} +0 -0
  112. /package/dist/{chunk-6KK26F2T.js.map → chunk-BTY4LZBG.js.map} +0 -0
  113. /package/dist/{chunk-Q7YZL7PG.js.map → chunk-CS5JF52J.js.map} +0 -0
  114. /package/dist/{chunk-5NS4CNF6.js.map → chunk-E2RFM6R2.js.map} +0 -0
  115. /package/dist/{chunk-BSEB55E6.js.map → chunk-EOY6BK4C.js.map} +0 -0
  116. /package/dist/{chunk-ZBV5IV5T.js.map → chunk-IKCP5NCE.js.map} +0 -0
  117. /package/dist/{chunk-DF22CTXE.js.map → chunk-IX2QLW6G.js.map} +0 -0
  118. /package/dist/{chunk-65N4ZPQD.js.map → chunk-JAC6JVCI.js.map} +0 -0
  119. /package/dist/{chunk-V6PXHQSI.js.map → chunk-JWSEPW7F.js.map} +0 -0
  120. /package/dist/{chunk-AS5VL32C.js.map → chunk-JYALBYN7.js.map} +0 -0
  121. /package/dist/{chunk-R2TAVQGZ.js.map → chunk-K2JTERIO.js.map} +0 -0
  122. /package/dist/{chunk-U4W4LULB.js.map → chunk-MGIOV72F.js.map} +0 -0
  123. /package/dist/{chunk-ORQKMXHA.js.map → chunk-MZPS46OR.js.map} +0 -0
  124. /package/dist/{chunk-K2Z3KGOH.js.map → chunk-NPMAATZG.js.map} +0 -0
  125. /package/dist/{chunk-KQDAFZKR.js.map → chunk-Q4WWS3UQ.js.map} +0 -0
  126. /package/dist/{chunk-A2FKWRKO.js.map → chunk-R3N4AIKS.js.map} +0 -0
  127. /package/dist/{chunk-DCTEL4KG.js.map → chunk-RVXMK4X2.js.map} +0 -0
  128. /package/dist/{chunk-LD4CHA7U.js.map → chunk-UKL7GWEH.js.map} +0 -0
  129. /package/dist/{chunk-4VWTIT5C.js.map → chunk-UWXDNVS5.js.map} +0 -0
  130. /package/dist/{chunk-U6IWRZQF.js.map → chunk-VNNCYWNN.js.map} +0 -0
  131. /package/dist/{chunk-7U3V64YT.js.map → chunk-WKLQFSV6.js.map} +0 -0
  132. /package/dist/{chunk-WD5BQBVY.js.map → chunk-Z5SOZUUB.js.map} +0 -0
  133. /package/dist/{chunk-AQ5WISEG.js.map → chunk-ZCQVKDHV.js.map} +0 -0
  134. /package/dist/{chunk-RCSOG2DV.js.map → chunk-ZINMEMOB.js.map} +0 -0
  135. /package/dist/{creatives-U2M4F3D5.js.map → creatives-NK5HOXSF.js.map} +0 -0
  136. /package/dist/{critique-43OVWKN7.js.map → critique-EDMP5P5R.js.map} +0 -0
  137. /package/dist/{critique-JVKJEBAC.js.map → critique-N5OL42C6.js.map} +0 -0
  138. /package/dist/{customers-P4N4NXLJ.js.map → customers-TLAHWJY6.js.map} +0 -0
  139. /package/dist/{feedback-3GU3PAEI.js.map → feedback-OCN3XNKF.js.map} +0 -0
  140. /package/dist/{feedback-record-PIJDOJW3.js.map → feedback-record-Z66AXZ57.js.map} +0 -0
  141. /package/dist/{fit-TVQ7RK52.js.map → fit-PMSNW2PF.js.map} +0 -0
  142. /package/dist/{fonts-BMUNDGOZ.js.map → fonts-I434ILTG.js.map} +0 -0
  143. /package/dist/{generate-4HWNFAH3.js.map → generate-OMXBFGGR.js.map} +0 -0
  144. /package/dist/{ideas-UTSCGCT6.js.map → ideas-K6FQVDUA.js.map} +0 -0
  145. /package/dist/{landing-AJO2BPC2.js.map → landing-EJGYTI5W.js.map} +0 -0
  146. /package/dist/{learn-RGO5KDHS.js.map → learn-66SKYR36.js.map} +0 -0
  147. /package/dist/{models-2DQ5NBMT.js.map → models-2XRYXSRA.js.map} +0 -0
  148. /package/dist/{rerun-R3DNEV5U.js.map → rerun-DZKHTK66.js.map} +0 -0
  149. /package/dist/{research-MBAPL35Y.js.map → research-L2DH5P22.js.map} +0 -0
  150. /package/dist/{rules-SZIY67QF.js.map → rules-TPW37OVS.js.map} +0 -0
  151. /package/dist/{rules-add-KTLHU3YD.js.map → rules-add-HTL6IFQJ.js.map} +0 -0
  152. /package/dist/{run-QYIUO4NB.js.map → run-EID2OD4U.js.map} +0 -0
  153. /package/dist/{scaffold-ad-NIVJSO73.js.map → scaffold-ad-SQZMHTRA.js.map} +0 -0
  154. /package/dist/{scaffold-static-ad-QX2NUXFR.js.map → scaffold-static-ad-L2JCW5LF.js.map} +0 -0
  155. /package/dist/{scaffold-video-NXBM54K3.js.map → scaffold-video-2WLFALNV.js.map} +0 -0
  156. /package/dist/{select-Q4S4CPKV.js.map → select-POYNXE2L.js.map} +0 -0
  157. /package/dist/{set-prompt-3MVZW3L6.js.map → set-prompt-2OXPI4ZF.js.map} +0 -0
  158. /package/dist/{stale-NT2JRQHY.js.map → stale-6HL4ELJW.js.map} +0 -0
  159. /package/dist/{studio-YB5WXQYC.js.map → studio-MARZ22J2.js.map} +0 -0
  160. /package/dist/{sync-definition-6XPX6VJU.js.map → sync-definition-VVNXDNDC.js.map} +0 -0
  161. /package/dist/{translate-27DIFMBU.js.map → translate-ACGKNKQP.js.map} +0 -0
  162. /package/dist/{validate-AYPLNS7A.js.map → validate-SUW24MMI.js.map} +0 -0
  163. /package/dist/{viewer-check-TSH3SAYJ.js.map → viewer-check-7S2EB32L.js.map} +0 -0
  164. /package/dist/{winning-ads-SGBI3WHK.js.map → winning-ads-T4MOKDYT.js.map} +0 -0
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  outputRatioWarningsFor,
3
3
  shownBaseline
4
- } from "./chunk-5YKC2WWG.js";
4
+ } from "./chunk-4S4WDXJR.js";
5
5
  import {
6
6
  creativeSlugFromCanvasPath
7
- } from "./chunk-4VWTIT5C.js";
8
- import "./chunk-KQDAFZKR.js";
7
+ } from "./chunk-UWXDNVS5.js";
8
+ import "./chunk-Q4WWS3UQ.js";
9
9
  import {
10
10
  exitOnPrepareError,
11
11
  prepareCanvas
12
- } from "./chunk-5RCCESDX.js";
13
- import "./chunk-BSEB55E6.js";
14
- import "./chunk-RCSOG2DV.js";
15
- import "./chunk-LD4CHA7U.js";
12
+ } from "./chunk-AXDKLXCG.js";
13
+ import "./chunk-EOY6BK4C.js";
14
+ import "./chunk-ZINMEMOB.js";
15
+ import "./chunk-UKL7GWEH.js";
16
16
  import "./chunk-LCW3U4EA.js";
17
- import "./chunk-7U3V64YT.js";
18
- import "./chunk-MMVLRUMK.js";
19
- import "./chunk-R2TAVQGZ.js";
20
- import "./chunk-DF22CTXE.js";
21
- import "./chunk-AS5VL32C.js";
17
+ import "./chunk-WKLQFSV6.js";
18
+ import "./chunk-G2LGMWNG.js";
19
+ import "./chunk-K2JTERIO.js";
20
+ import "./chunk-IX2QLW6G.js";
21
+ import "./chunk-JYALBYN7.js";
22
22
  import "./chunk-FNA277HP.js";
23
23
  import "./chunk-5WMTPYKT.js";
24
24
  import {
@@ -27,14 +27,14 @@ import {
27
27
  import {
28
28
  defaultRegistry,
29
29
  validateCanvasDeep
30
- } from "./chunk-GQ6JS5MR.js";
31
- import "./chunk-ELL2IQMF.js";
32
- import "./chunk-5NS4CNF6.js";
30
+ } from "./chunk-4VB7F422.js";
31
+ import "./chunk-62JQQUAU.js";
32
+ import "./chunk-E2RFM6R2.js";
33
33
  import "./chunk-DGCUPJZD.js";
34
- import "./chunk-6KK26F2T.js";
35
- import "./chunk-U2452GLO.js";
36
- import "./chunk-ZBV5IV5T.js";
37
- import "./chunk-T6ATGN7Y.js";
34
+ import "./chunk-BTY4LZBG.js";
35
+ import "./chunk-4AMIHNNP.js";
36
+ import "./chunk-IKCP5NCE.js";
37
+ import "./chunk-MCJ5I5LR.js";
38
38
  import "./chunk-KPYDTIAI.js";
39
39
  import "./chunk-KIGGMKAE.js";
40
40
  import "./chunk-DWX44QL6.js";
@@ -114,4 +114,4 @@ var validateCommand = defineCommand({
114
114
  export {
115
115
  validateCommand
116
116
  };
117
- //# sourceMappingURL=validate-AYPLNS7A.js.map
117
+ //# sourceMappingURL=validate-SUW24MMI.js.map
@@ -22,20 +22,20 @@ import {
22
22
  viewerCheckCommand,
23
23
  viewerCheckFailure,
24
24
  viewerCheckSkip
25
- } from "./chunk-RTWRNG3E.js";
26
- import "./chunk-RCSOG2DV.js";
27
- import "./chunk-LD4CHA7U.js";
25
+ } from "./chunk-IN6AW5P3.js";
26
+ import "./chunk-ZINMEMOB.js";
27
+ import "./chunk-UKL7GWEH.js";
28
28
  import "./chunk-LCW3U4EA.js";
29
- import "./chunk-7U3V64YT.js";
30
- import "./chunk-MMVLRUMK.js";
31
- import "./chunk-AS5VL32C.js";
29
+ import "./chunk-WKLQFSV6.js";
30
+ import "./chunk-G2LGMWNG.js";
31
+ import "./chunk-JYALBYN7.js";
32
32
  import "./chunk-BITS62MF.js";
33
33
  import "./chunk-FNA277HP.js";
34
34
  import "./chunk-5WMTPYKT.js";
35
35
  import "./chunk-23H4ZJRP.js";
36
- import "./chunk-U2452GLO.js";
37
- import "./chunk-ZBV5IV5T.js";
38
- import "./chunk-T6ATGN7Y.js";
36
+ import "./chunk-4AMIHNNP.js";
37
+ import "./chunk-IKCP5NCE.js";
38
+ import "./chunk-MCJ5I5LR.js";
39
39
  import "./chunk-KPYDTIAI.js";
40
40
  import "./chunk-KIGGMKAE.js";
41
41
  import "./chunk-DWX44QL6.js";
@@ -77,4 +77,4 @@ export {
77
77
  viewerCheckFailure,
78
78
  viewerCheckSkip
79
79
  };
80
- //# sourceMappingURL=viewer-check-TSH3SAYJ.js.map
80
+ //# sourceMappingURL=viewer-check-7S2EB32L.js.map
@@ -70,7 +70,7 @@ Full guide: __tooling__/docs/tools/baker/winning-ads.md`
70
70
  landings: () => import("./landings-ZLKUP66P.js").then((m) => m.landingsCommand),
71
71
  "search-copy": () => import("./search-copy-N2AIJNUH.js").then((m) => m.searchCopyCommand),
72
72
  content: () => import("./content-KA25YYO3.js").then((m) => m.contentCommand),
73
- fit: () => import("./fit-TVQ7RK52.js").then((m) => m.fitCommand),
73
+ fit: () => import("./fit-PMSNW2PF.js").then((m) => m.fitCommand),
74
74
  unfollow: () => import("./unfollow-ZI5QU7RD.js").then((m) => m.unfollowCommand),
75
75
  refresh: () => import("./refresh-RQ3C2MHI.js").then((m) => m.refreshCommand),
76
76
  hooks: () => import("./seeds-EYYQCMGF.js").then((m) => m.hooksCommand),
@@ -81,4 +81,4 @@ Full guide: __tooling__/docs/tools/baker/winning-ads.md`
81
81
  export {
82
82
  winningAdsCommand
83
83
  };
84
- //# sourceMappingURL=winning-ads-SGBI3WHK.js.map
84
+ //# sourceMappingURL=winning-ads-T4MOKDYT.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koda-sl/baker-cli",
3
- "version": "0.482.0",
3
+ "version": "0.483.0",
4
4
  "description": "AI-agent-first CLI for interacting with Baker, including the Baker creative canvas.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/winning-ads/fit.ts","../src/commands/canvas/library-reference.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\n/**\n * Does this winning ad fit this company, and what would we have to supply to keep why it won?\n *\n * Audited Sept 2026: of 33 creatives built from winning ads, 12 lost the concept. References\n * were picked whose load-bearing ingredient we could not supply (a gift, a peer's voice, priced\n * tiers, a native disguise our \"big logo, big button\" rule broke), and nothing said so until the\n * finished ad came back as a feature list in a notes app. So before scaffolding, one vision call\n * reads the reference beside what the company has (COMPANY.md, the brand's rules, the offers,\n * products and personas in the Knowledge, its reviews, its Avatars) and says, in layers, why the ad\n * wins, what each load-bearing element needs, whether we have it, and a verdict: use, adapt or\n * reject. Always among them what stops the scroll and the proof (Oct 2026: a meme's fit left out the\n * reaction faces it stopped the scroll with), each kept, replaced with ours or impossible, the rule\n * that forbids one quoted; either impossible is a reject. The agent checks about three candidates and\n * scaffolds only one that fits; the scaffold seeds the ad spec's `concept` from the verdict, and\n * `baker canvas run` refuses a `reject`.\n */\nimport { mkdir, readdir, readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { AvatarsListResponse } from \"@baker/api\";\nimport { AD_DESCRIBE_MODEL } from \"@baker/canvas-contract\";\nimport { defineCommand } from \"citty\";\nimport sharp from \"sharp\";\nimport { z } from \"zod\";\nimport { apiGet } from \"../../client.ts\";\nimport { memeRegister, readCompanyReading } from \"../../engine/creative-context/company.ts\";\nimport { type ContextReaders, type CreativeContext, readCreativeContext } from \"../../engine/creative-context/index.ts\";\nimport { rulesBlock } from \"../../engine/creative-rules/select.ts\";\nimport { askAboutImages, type ReviewUsage } from \"../../engine/nodes/local/lib/render-review.ts\";\nimport { bytesOf } from \"../../engine/nodes/local/lib/static-review.ts\";\nimport {\n CONCEPT_CARRY_LEVELS,\n decisionOf,\n LOAD_BEARING_FIELDS,\n type MemeAudience,\n unfitReasons,\n withDerivedHave,\n} from \"../../engine/scaffold/static-ad-spec.ts\";\nimport { writeJson } from \"../../output.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { readAvatars } from \"../avatars/transport.ts\";\nimport {\n type DesignRefusal,\n fetchLibraryReference,\n LIBRARY_PLATFORMS,\n type LibraryPlatform,\n notADesignReference,\n resolveSourcePlatform,\n} from \"../canvas/library-reference.ts\";\nimport { findWorkspaceRoot } from \"../canvas/normalize-paths.ts\";\nimport { holdUnbilledSpend } from \"../canvas/unbilled-spend.ts\";\nimport { avatarsOf, castCompany } from \"../creatives/cast-inventory.ts\";\n\nconst Layers = z\n .object({\n disguise: z.string().optional(),\n voice: z.string().optional(),\n trigger: z.string().optional(),\n attention: z.string().optional(),\n logic: z.string().optional(),\n })\n .strip();\n\n/**\n * What the fit model answers. A read that names no element stopping the scroll or no proof is no read\n * of why the ad won, and is asked again (a fit cached before either was asked for is read again too).\n */\nexport const FitAnswerSchema = z\n .object({\n why_it_wins: Layers.default({}),\n load_bearing: z.array(z.preprocess(withDerivedHave, z.object(LOAD_BEARING_FIELDS).strip())).default([]),\n verdict: z.enum([\"use\", \"adapt\", \"reject\"]),\n transfer_note: z.string().optional(),\n brand_presence: z.enum([\"native\", \"standard\"]).optional(),\n recognition: z.string().optional(),\n carry: z.enum(CONCEPT_CARRY_LEVELS).optional(),\n carry_why: z.string().optional(),\n /** Asked only with a bet: would the viewer of the ad we are making stop for this one. */\n our_viewer: z\n .object({ stops: z.enum([\"yes\", \"maybe\", \"no\"]), why: z.string().default(\"\") })\n .strip()\n .optional()\n .catch(undefined),\n })\n .refine((fit) => fit.load_bearing.some((l) => l.job === \"stop\") && fit.load_bearing.some((l) => l.job === \"proof\"), {\n message: \"name what stops the scroll (job: stop) and the proof (job: proof) among load_bearing\",\n })\n // An element it wins on that nothing of ours may carry is a reject, whatever the model's verdict.\n .transform((fit) =>\n fit.verdict !== \"reject\" && fit.load_bearing.some((l) => decisionOf(l) === \"impossible\")\n ? { ...fit, verdict: \"reject\" as const }\n : fit,\n );\n\n/** The ad we are making, as the fit judges a reference for it. */\nexport type FitBet = {\n who: string;\n message: string;\n awareness?: string;\n angle?: string;\n /** Our customers' own words the idea stands on. */\n quotes?: readonly string[];\n /** The viewer's market in words (`describeMarket`). */\n market?: string;\n};\nexport type FitAnswer = z.infer<typeof FitAnswerSchema>;\n\n/** The library's read of the reference, as far as the fit needs it. */\nexport type FitLibraryRead = {\n advertiser?: string;\n format_pattern?: string;\n mechanism?: string;\n awareness?: string;\n offer?: string;\n text?: string[];\n /** The library's evidence that it won: winner, scaled_winner, evergreen, rising. */\n winner_category?: string;\n angle?: string;\n hook_archetype?: string;\n composition?: string;\n};\n\n/** Whether our brand's voice runs memes: the company's reading (`memeRegister`), kept with the fit. */\ntype FitAudience = MemeAudience;\n\n/** The line that tells the fit our brand's voice does not run memes, and why. Pure. */\nfunction audienceLines(audience: FitAudience | undefined): string[] {\n return audience?.memes === \"off_brand\"\n ? [\n `Our brand's voice does not run memes${audience.why ? ` (${audience.why})` : \"\"}: a meme or a reaction face that does the stop job is impossible for us (decision impossible, rule: our brand's voice does not run memes), and the verdict is reject.`,\n ]\n : [];\n}\n\n/** The fit with its verdict set to reject when its scroll-stopper is a meme our audience does not read. Pure. */\nexport function rejectForAudience(fit: FitAnswer, audience: FitAudience | undefined): FitAnswer {\n const reasons = unfitReasons(fit, audience).filter((r) => r.includes(\"does not run memes\"));\n if (reasons.length === 0) return fit;\n return { ...fit, verdict: \"reject\", transfer_note: reasons.join(\"; \") };\n}\n\n/** The key a fit is kept under besides its ad: the bet it was made for and the register it was read in; none for neither. Pure. */\nexport function fitKeyOf(bet: FitBet | undefined, audience: FitAudience | undefined): string | undefined {\n const parts = [bet ? JSON.stringify(bet) : \"\", audience ? `memes:${audience.memes}:${audience.why ?? \"\"}` : \"\"];\n return parts.some(Boolean) ? parts.join(\"|\") : undefined;\n}\n\n/** A person the company may show in its ads: one of its Avatars (`castInventory`'s). */\ntype FitCast = { handle: string; real: boolean; who: string; relation: string; castable: boolean };\n\n/** Who the company may show, as the fit reads it: its team's, founder's and made-for-a-role Avatars; a customer's only in their own testimonial. Pure. */\nfunction castLines(cast: readonly FitCast[]): string[] {\n const ours = cast\n .filter((a) => a.castable)\n .map((a) => `@${a.handle} (${a.real ? \"a real person\" : \"made for a role\"}: ${a.who})`);\n const theirs = cast\n .filter((a) => !a.castable)\n .map(\n (a) =>\n `@${a.handle}: a ${a.relation === \"unknown\" ? \"customer\" : a.relation} (${a.who}); only in an ad quoting their own published words, never a reaction face or a model`,\n );\n return [\n `The people OUR ads may show: our team's, founder's or a made-for-a-role Avatar${ours.length > 0 ? ` (${ours.join(\"; \")})` : \" (none made yet)\"}, unless our rules forbid made-up people.`,\n ...(theirs.length > 0\n ? [\n `Avatars of people who are not ours to cast: ${theirs.join(\"; \")}. A customer's face appears only in a testimonial ad that quotes them.`,\n ]\n : [\"A customer's face appears only in a testimonial ad that quotes them.\"]),\n ];\n}\n\n/**\n * The fit model's prompt: the company first, then the question, the answer a fixed JSON the code\n * reads. The layers are the ones the ad spec's `concept` keeps. Pure.\n */\nexport function buildFitPrompt(input: {\n library: FitLibraryRead;\n knowledge: string;\n bet?: FitBet;\n /** The company's Avatars, when they could be read. */\n cast?: readonly FitCast[];\n /** Whether its audience reads memes. */\n audience?: FitAudience;\n}): string {\n const facts = libraryFacts(input.library);\n return [\n \"The image is a winning ad by another advertiser. We want to build an ad for OUR company on its concept: keep why it wins, change everything else to ours.\",\n ...(facts.length > 0 ? [`The ads library read it as: ${facts.join(\". \")}.`] : []),\n \"\",\n \"What OUR company has (its own documents):\",\n input.knowledge.trim() || \"(nothing written down yet)\",\n ...(input.cast ? castLines(input.cast) : []),\n ...audienceLines(input.audience),\n \"\",\n ...(input.bet ? [...betLines(input.bet), \"\"] : []),\n \"Answer in English:\",\n \"why_it_wins, in layers, one short phrase each, empty when a layer does nothing: disguise (what the ad pretends to be: a note, a tweet, a newspaper, a chat, a plain ad), voice (who speaks and how: a peer, a founder, a brand), trigger (the emotion or need it pulls: a free gift, fear of a hidden loss, status, curiosity), attention (what stops the scroll), logic (why it convinces: reciprocity, social proof, a comparison, a price anchor).\",\n 'load_bearing: the 2-5 elements the ad stops working without (never decoration), always these two: what stops the scroll (job \"stop\": the face or reaction, the joke, the meme people know, the odd photo; when attention names a face, that face is it) and the proof that makes it believed (job \"proof\": the ✗/✓ checklist, the before and after, the rating, the result shown), then any other its why_it_wins rests on (job \"other\"). Name each as it shows in the picture (\"the two reaction faces of a famous sitcom boss\", \"the red ✗ and green ✓ marks before each line\"), never as an idea (\"a contrast\", \"relatable fatigue\").',\n \"Each with: element, job, needs (what it takes to carry it), have (have: we have it as it is; adapt: something of ours can do its job; missing: we have nothing that does), decision (keep: as it is; replace: with something of ours that does the same job, named in ours; impossible: nothing of ours may do its job; a person is never kept as theirs: the advertiser's own people, or a celebrity who is not a meme template, are replaced with one of ours; a famous meme's job is done by a meme our buyer persona knows and relates to, from `baker images meme`, our words on it, whenever our brand's voice runs memes: the proven ad's own template only when it is also the one our persona knows best; a two-panel reaction meme becomes two real templates, top and bottom; never a customer's face: a customer appears only in an ad quoting their own words), ours (what of ours does its job, concretely, one thing of ours, never a choice between two: a meme our buyer persona knows and relates to, from `baker images meme` with our words, our team's, founder's or a made-for-a-role Avatar, the ✓/✗ marks in our colours; never invent an offer, a gift, a price, a review or a customer we do not have), rule (only when one of the company's rules forbids it as it is: that rule, quoted word for word).\",\n \"A rule forbids only what it names: \\\"no stock photography\\\" forbids stock photos, never a meme's reaction face, the company's own people or its Avatars; a rule on logos, buttons or colours says nothing about faces.\",\n \"verdict: use (it transfers as it is), adapt (it transfers with ours in place of theirs), reject (what stops the scroll, the proof or another load-bearing element is impossible for us: without it our version loses why it wins).\",\n \"transfer_note: one sentence on how the idea becomes ours, or why it cannot.\",\n \"brand_presence: native when the disguise only works without looking like an ad (the logo as the sender's picture, no big button), else standard.\",\n 'recognition: what kind of product a stranger must take OUR version for in one second, never its format (\"a trade course\", \"a social media API for developers\", \"a payroll app\").',\n \"carry: what made it a winner, so what OUR ad takes from it: whole_ad (it wins as one piece: its disguise, layout and hook together; ours keeps all three with our words, brand and pictures), layout (its composition or container does the work: ours keeps that arrangement), hook (its opening line or first visual stops the scroll: ours opens on the same pattern in our words), angle (the argument or need it pulls wins, its look is ordinary: ours keeps the argument and looks like ours). carry_why: one sentence on why that level.\",\n ...(input.bet\n ? [\n \"our_viewer: would the viewer of the ad we are making stop on THIS ad's move, made ours? stops: yes, maybe or no; why: one sentence naming what in it would or would not reach them (their age, life, market, what they care about). An ad that wins with another audience is no reference for ours.\",\n ]\n : []),\n \"\",\n `Reply with only this JSON: {\"why_it_wins\":{\"disguise\":\"\",\"voice\":\"\",\"trigger\":\"\",\"attention\":\"\",\"logic\":\"\"},\"load_bearing\":[{\"element\":\"\",\"job\":\"stop|proof|other\",\"needs\":\"\",\"have\":\"have|adapt|missing\",\"decision\":\"keep|replace|impossible\",\"ours\":\"\",\"rule\":\"\"}],\"verdict\":\"use|adapt|reject\",\"transfer_note\":\"\",\"brand_presence\":\"native|standard\",\"recognition\":\"\",\"carry\":\"whole_ad|layout|hook|angle\",\"carry_why\":\"\"${input.bet ? ',\"our_viewer\":{\"stops\":\"yes|maybe|no\",\"why\":\"\"}' : \"\"}}`,\n ].join(\"\\n\");\n}\n\n/** The library's read of a reference, as lines the fit prompt quotes. Pure. */\nfunction libraryFacts(lib: FitLibraryRead): string[] {\n return [\n lib.advertiser ? `advertiser: ${lib.advertiser}` : \"\",\n lib.format_pattern ? `container: ${lib.format_pattern}` : \"\",\n lib.mechanism ? `persuasion mechanism: ${lib.mechanism}` : \"\",\n lib.awareness ? `awareness stage: ${lib.awareness}` : \"\",\n lib.offer ? `offer: ${lib.offer}` : \"\",\n lib.winner_category ? `evidence it won: ${lib.winner_category}` : \"\",\n lib.angle ? `angle: ${lib.angle}` : \"\",\n lib.hook_archetype ? `hook: ${lib.hook_archetype}` : \"\",\n lib.composition ? `composition: ${lib.composition}` : \"\",\n lib.text && lib.text.length > 0 ? `its words: ${lib.text.map((t) => `\"${t}\"`).join(\"; \")}` : \"\",\n ].filter(Boolean);\n}\n\n/** The ad we are making, as the fit reads it: who it is for, what it says, in our customers' words. Pure. */\nfunction betLines(bet: FitBet): string[] {\n return [\n \"The ad we are making with it:\",\n `- For: ${bet.who}${bet.market ? `, ${bet.market}` : \"\"}${bet.awareness ? `; awareness: ${bet.awareness}` : \"\"}`,\n `- It says: ${bet.message}${bet.angle ? ` (angle: ${bet.angle})` : \"\"}`,\n ...(bet.quotes && bet.quotes.length > 0\n ? [`- In our customers' own words: ${bet.quotes.map((q) => `\"${q}\"`).join(\"; \")}`]\n : []),\n ];\n}\n\n/** What the agent does next with a fit. Pure. */\nexport function fitHints(fit: FitAnswer, adId: string, platform = \"meta\", audience?: FitAudience): string[] {\n const reasons = unfitReasons(fit, audience);\n if (fit.verdict === \"reject\" || reasons.length > 0) {\n return [\n `Pick another reference: ${reasons.length > 0 ? reasons.join(\"; \") : \"this one wins on something we cannot supply\"}, and our version would lose why it won.${fit.transfer_note ? ` ${fit.transfer_note}` : \"\"} Do not stop or ask the person: check the next candidates (\\`baker winning-ads fit <adId> --platform ${platform}\\`, about three) and scaffold the first that fits.`,\n ];\n }\n const keeps = fit.load_bearing.map((l) => {\n const job = l.job === \"stop\" ? \"what stops the scroll\" : l.job === \"proof\" ? \"the proof\" : `\"${l.element}\"`;\n return decisionOf(l) === \"replace\" && l.ours?.trim() ? `${job} as \"${l.ours.trim()}\"` : `\"${l.element}\"`;\n });\n return [\n `It fits (${fit.verdict}). Scaffold it: \\`baker canvas scaffold-static-ad --source-ad-id ${adId} --source-platform ${platform} --slug <slug>\\`: prompt.json's \\`concept\\` is seeded from this fit, and every render keeps ${keeps.join(\", \") || \"its idea\"}.`,\n ...(fit.brand_presence === \"native\"\n ? [\n \"The concept is a native disguise: the brand shows as the sender (the logo small, as its picture or signature) and there is no big button; prompt.json says `brand_presence: native`.\",\n ]\n : []),\n ];\n}\n\n/** How the scaffold's hint for a reference built on with no fit opens (`creatives make` drops it once it checked the reference). */\nexport const NO_FIT_HINT = \"No fit was made of this reference\";\n\n/** The ad spec fields a fit seeds: `concept`, `brand_presence`, `recognition`. Pure. */\nexport function conceptFromFit(fit: FitAnswer, adId: string) {\n return {\n concept: {\n reference_ad_id: adId,\n why_it_wins: fit.why_it_wins,\n load_bearing: fit.load_bearing,\n verdict: fit.verdict,\n ...(fit.transfer_note ? { transfer_note: fit.transfer_note } : {}),\n // A fit that names no level (cached before `carry`) is read as the whole ad, and says so.\n carry: fit.carry ?? \"whole_ad\",\n ...(fit.carry_why ? { carry_why: fit.carry_why } : {}),\n },\n ...(fit.brand_presence ? { brand_presence: fit.brand_presence } : {}),\n ...(fit.recognition ? { recognition: fit.recognition } : {}),\n };\n}\n\nconst MAX_DOC_CHARS = 6000;\nconst MAX_ENTRY_CHARS = 1200;\nconst KNOWLEDGE_COLLECTIONS = [\"offers\", \"products\", \"personas\", \"positioning\"] as const;\n\nfunction readText(file: string): Promise<string | null> {\n return readFile(file, \"utf8\").catch(() => null);\n}\n\n/** How the brand speaks and looks and which logo its ads use, as its reading says. Pure. */\nfunction brandLines(brand: CreativeContext[\"brand\"]): string {\n const lines = [\n ...(brand?.voice ? [`Voice: ${brand.voice}`] : []),\n ...(brand?.imagery ? [`Pictures: ${brand.imagery}`] : []),\n ...(brand?.logoUsage ? [`Logo: ${brand.logoUsage}`] : []),\n ];\n return lines.length > 0 ? `The brand:\\n${lines.join(\"\\n\")}` : \"\";\n}\n\n/**\n * What the company has, as the fit reads it: COMPANY.md (the records of what it has), how its brand\n * speaks and looks, every rule it sets for a static ad, and every entry of the offers, products and\n * personas in the Knowledge, each cut short. Never throws.\n */\nexport async function readKnowledge(root: string, readers?: ContextReaders): Promise<string> {\n const parts: string[] = [];\n const company = await readText(path.join(root, \"COMPANY.md\"));\n if (company) parts.push(`COMPANY.md:\\n${company.slice(0, MAX_DOC_CHARS)}`);\n const context = await readCreativeContext(root, { kind: \"static\" }, readers ? { readers } : {});\n const brand = brandLines(context.brand);\n if (brand) parts.push(brand);\n const rules = rulesBlock(context.rules);\n if (rules) parts.push(rules);\n for (const collection of KNOWLEDGE_COLLECTIONS) {\n const dir = path.join(root, \"src\", \"content\", collection);\n const files = ((await readdir(dir, { recursive: true }).catch(() => [])) as string[]).filter((f) =>\n f.endsWith(\".md\"),\n );\n for (const file of files.sort().slice(0, 12)) {\n const text = await readText(path.join(dir, file));\n if (text) parts.push(`${collection}/${file}:\\n${text.slice(0, MAX_ENTRY_CHARS)}`);\n }\n }\n return parts.join(\"\\n\\n\");\n}\n\n/** One review as the testimonials route returns it, read loosely so a new field never empties the list. */\nconst ReviewSchema = z.object({\n reviewText: z.string(),\n sourceType: z.string().optional(),\n rating: z.number().optional(),\n});\n\n/** The company's reviews (`/api/testimonials`, a plain list), as a few lines the fit can weigh proof against. Pure. */\nexport function reviewsForFit(data: unknown): string {\n const list = Array.isArray(data) ? data : [];\n const lines = list.slice(0, 15).flatMap((item) => {\n const review = ReviewSchema.safeParse(item);\n if (!review.success || !review.data.reviewText.trim()) return [];\n const { reviewText, sourceType, rating } = review.data;\n const label = [sourceType, rating !== undefined ? `${rating}★` : \"\"].filter(Boolean).join(\" \");\n return [`- ${label ? `${label} ` : \"\"}\"${reviewText.slice(0, 160)}\"`];\n });\n return lines.length > 0\n ? `Reviews we have (${lines.length}):\\n${lines.join(\"\\n\")}`\n : \"Reviews we have: none on file.\";\n}\n\n/** The company's reviews for the fit. Never throws. */\nasync function readReviews(): Promise<string> {\n try {\n return reviewsForFit(await apiGet<unknown>(\"/api/testimonials\", { limit: \"15\" }));\n } catch {\n return \"\";\n }\n}\n\n/** Where a fit is kept, so the scaffold of the same reference seeds its concept from it. */\nexport function fitCachePath(root: string, platform: string, adId: string): string {\n return path.join(root, \"canvas\", \".cache\", \"fit\", `${platform}-${adId.replace(/[^a-zA-Z0-9_-]/g, \"_\")}.json`);\n}\n\n/** The fit this workspace made of a reference, or null. Never throws. */\nexport function readCachedFit(root: string, platform: string, adId: string): Promise<FitAnswer | null> {\n return readFitFile(fitCachePath(root, platform, adId));\n}\n\n/** A cached fit file's answer, or null. Never throws. */\nasync function readFitFile(file: string): Promise<FitAnswer | null> {\n const raw = await readText(file);\n if (!raw) return null;\n try {\n const parsed = FitAnswerSchema.safeParse(JSON.parse(raw));\n return parsed.success ? parsed.data : null;\n } catch {\n return null;\n }\n}\n\nconst DESCRIPTION =\n \"Does a winning ad fit this company? One vision call reads the reference beside what the company has (COMPANY.md, the brand's rules, the offers, products and personas in the Knowledge, its reviews, its Avatars) and says why the ad wins (disguise, voice, trigger, attention, logic), the elements it stops working without (always what stops the scroll, `job: stop`, and its proof, `job: proof`), what our ad does with each (`decision`: keep, replace with `ours`, or impossible, quoting the `rule` that forbids it), and a verdict: use, adapt or reject (a stop or proof that is impossible for us is a reject). Start here before scaffolding a static ad from the library: check about three candidates, scaffold only one that fits. `baker canvas scaffold-static-ad --source-ad-id <adId>` then seeds prompt.json's `concept` from this verdict, and a run refuses a rejected concept. Example: baker winning-ads fit 1310524137919413 --platform meta. Output is compact; --full adds the whole read.\";\n\nconst ARGS = {\n \"ad-id\": { type: \"positional\", required: true, description: \"The library ad id (from search/winners/feed).\" },\n platform: {\n type: \"string\",\n required: false,\n description: `Which platform the ad id is on: ${LIBRARY_PLATFORMS.join(\"|\")} (default meta). The fit reads a still picture: a static ad (on google, a display ad). A video ad, YouTube included, is read with \\`content\\`; a Google search, Shopping or app ad is refused.`,\n },\n full: {\n type: \"boolean\",\n required: false,\n default: false,\n description: \"Add the whole read: every layer, need and note.\",\n },\n} as const;\n\nregisterSchema({ command: \"winning-ads.fit\", description: DESCRIPTION, args: ARGS });\n\ntype LibraryAd = Awaited<ReturnType<typeof fetchLibraryReference>>;\n\n/** The reference's picture as a JPEG the vision model reads, null when it has none to read. */\n/** A picture as the vision models read it: a JPEG at most 1024 px, base64; null when it cannot be read. */\nexport async function pictureOf(url: string | null | undefined): Promise<string | null> {\n if (!url) return null;\n try {\n const bytes = await bytesOf(url);\n return (await sharp(bytes).resize(1024, 1024, { fit: \"inside\" }).jpeg({ quality: 85 }).toBuffer()).toString(\n \"base64\",\n );\n } catch {\n return null;\n }\n}\n\n/** What the library already read of the ad, to ground the fit. */\nfunction libraryRead(ad: LibraryAd) {\n return {\n ...(ad.advertiser ? { advertiser: ad.advertiser } : {}),\n ...(ad.layout.format_pattern ? { format_pattern: ad.layout.format_pattern } : {}),\n ...(ad.message.mechanism ? { mechanism: ad.message.mechanism } : {}),\n ...(ad.message.awareness_stage ? { awareness: ad.message.awareness_stage } : {}),\n ...(ad.offer.offer_type ? { offer: ad.offer.offer_type } : {}),\n ...(ad.winner_category ? { winner_category: ad.winner_category } : {}),\n ...(ad.angle ? { angle: ad.angle } : {}),\n ...(ad.hook_archetype ? { hook_archetype: ad.hook_archetype } : {}),\n ...(ad.layout.composition ? { composition: ad.layout.composition } : {}),\n text: ad.on_screen_text.flatMap((o) => (o.text ? [o.text] : [])).slice(0, 10),\n };\n}\n\n/**\n * The fit this workspace already made of the ad, else a new one from `ask`, kept for next time:\n * asking again is free, and a `reject` stays a reject (the scaffold's concept gate reads it).\n * With a `bet` key (the ad being made), a fit made for another bet is never reused: one ad can\n * suit one idea's viewer and not another's. The latest fit stays the ad's own, for its readers.\n */\nexport async function fitOnce(\n root: string,\n platform: string,\n adId: string,\n ask: () => Promise<FitAnswer | null>,\n bet?: string,\n): Promise<FitAnswer | null> {\n const betFile = bet ? fitCachePath(root, platform, `${adId}--${betKey(bet)}`) : null;\n const cached = betFile ? await readFitFile(betFile) : await readCachedFit(root, platform, adId);\n if (cached) return cached;\n const fit = await ask();\n if (!fit) return null;\n const text = `${JSON.stringify(fit, null, 2)}\\n`;\n for (const file of [betFile, fitCachePath(root, platform, adId)]) {\n if (!file) continue;\n await mkdir(path.dirname(file), { recursive: true });\n await writeFile(file, text, \"utf8\");\n }\n return fit;\n}\n\n/** A short stable key for a bet's text. Pure. */\nfunction betKey(bet: string): string {\n return createHash(\"sha256\").update(bet).digest(\"hex\").slice(0, 16);\n}\n\n/**\n * The first ask reads one reference for one ad the same way every time: whether what stops its\n * scroll can be ours decides the ad, and on dev the same question came back kept, replaced and\n * impossible on four asks. A reply out of shape is asked again as usual.\n */\nconst FIT_REQUEST = { temperature: 0, seed: 0 };\n\n/** The fit, asked at most twice; null when the model never answered in shape. */\nasync function askFit(jpeg: string, prompt: string, onSpend: (usage: ReviewUsage) => void): Promise<FitAnswer | null> {\n for (let attempt = 0; attempt < 2; attempt++) {\n const reply = await askAboutImages(\n AD_DESCRIBE_MODEL,\n [jpeg],\n prompt,\n onSpend,\n undefined,\n undefined,\n undefined,\n attempt === 0 ? FIT_REQUEST : {},\n );\n const parsed = FitAnswerSchema.safeParse(reply);\n if (parsed.success) return parsed.data;\n }\n return null;\n}\n\nexport type FitFailure =\n | { code: \"NOT_FOUND\" | \"UNAVAILABLE\" | \"VIDEO_REFERENCE\"; message: string; fix: string }\n | DesignRefusal;\n\n/** The library ad and its picture the fit reads, or why it cannot: never exits. */\nasync function readFitReference(\n adId: string,\n platform: LibraryPlatform,\n): Promise<{ ok: true; ad: LibraryAd; jpeg: string } | { ok: false; failure: FitFailure }> {\n let ad: LibraryAd;\n try {\n ad = await fetchLibraryReference(adId, platform);\n } catch (e) {\n return {\n ok: false,\n failure: {\n code: \"NOT_FOUND\",\n message: `The library could not return ad ${adId} on ${platform} (${e instanceof Error ? e.message : String(e)}).`,\n fix: \"Check the ad id and --platform against `baker winning-ads search`.\",\n },\n };\n }\n // A search text ad, a Shopping listing or an app-install ad is no design: never billed a fit.\n const refusal = notADesignReference(platform, adId, ad);\n if (refusal) return { ok: false, failure: refusal };\n // The fit reads one still picture: a video is studied whole with `content`, never fetched here.\n if (ad.format === \"video\") {\n return {\n ok: false,\n failure: {\n code: \"VIDEO_REFERENCE\",\n message: `Ad ${adId} is a video: the fit reads still pictures.`,\n fix: `Read it with \\`baker winning-ads content ${adId} --platform ${platform}\\` (transcript, on-screen text, pacing) and build the video with \\`baker canvas scaffold-ad\\`. For a static, pick a static ad.`,\n },\n };\n }\n const jpeg = await pictureOf(ad.media_url);\n if (!jpeg) {\n return {\n ok: false,\n failure: {\n code: \"NOT_FOUND\",\n message: `Ad ${adId} has no picture the fit can read.`,\n fix: \"Pick a static ad with a picture.\",\n },\n };\n }\n return { ok: true, ad, jpeg };\n}\n\n/**\n * The fit of one library ad for this workspace's company: cached, else one vision call. Never\n * exits; a reference the library cannot return, one with no picture, or a model that does not\n * answer is a failure the caller reports.\n */\nexport async function fitReference(\n root: string,\n platform: LibraryPlatform,\n adId: string,\n bet?: FitBet,\n): Promise<{ ok: true; fit: FitAnswer } | { ok: false; error: FitFailure }> {\n let failure = null as FitFailure | null;\n // Read before the cache: a fit made in another register is read again.\n const audience = memeRegister(await readCompanyReading(root).catch(() => null));\n const askFor = async () => {\n const read = await readFitReference(adId, platform);\n if (!read.ok) {\n failure = read.failure;\n return null;\n }\n const { ad, jpeg } = read;\n const knowledge = [await readKnowledge(root), await readReviews()].filter(Boolean).join(\"\\n\\n\");\n // Who we may show decides whether a face the reference stops the scroll with can be ours.\n const company = await castCompany(root);\n const cast = await readAvatars<AvatarsListResponse>(\"/api/avatars\", { status: \"ready\" }).then(\n (response) => avatarsOf(response, company),\n () => undefined,\n );\n const prompt = buildFitPrompt({\n library: libraryRead(ad),\n knowledge,\n ...(bet ? { bet } : {}),\n ...(cast ? { cast } : {}),\n ...(audience ? { audience } : {}),\n });\n const spent: ReviewUsage[] = [];\n const answer = await askFit(jpeg, prompt, (u) => spent.push(u));\n // No run record carries this call: the next render of this workspace bills it.\n await holdUnbilledSpend(path.join(root, \"canvas\", \".cache\"), spent);\n return answer && rejectForAudience(answer, audience);\n };\n // With no bet the ad's own file is the one `make` kept: a register-only key would look elsewhere and overwrite it.\n const fit = await fitOnce(root, platform, adId, askFor, bet ? fitKeyOf(bet, audience) : undefined);\n if (fit) return { ok: true, fit };\n return {\n ok: false,\n error: failure ?? {\n code: \"UNAVAILABLE\",\n message: \"The fit model did not answer (no gateway key here, or it failed twice).\",\n fix: \"Run it again, or read the reference yourself with `baker winning-ads content <adId> --full` and write prompt.json's `concept` by hand.\",\n },\n };\n}\n\nexport const fitCommand = defineCommand({\n meta: { name: \"fit\", description: DESCRIPTION },\n args: ARGS,\n async run({ args }) {\n const adId = String(args[\"ad-id\"]);\n const platformResult = resolveSourcePlatform(args.platform ? String(args.platform) : undefined);\n if (!platformResult.ok) {\n writeJson({ ok: false, error: { code: \"INVALID_ARGUMENT\", message: platformResult.message } });\n process.exit(1);\n }\n const platform = platformResult.platform;\n const root = findWorkspaceRoot(process.cwd()) ?? process.cwd();\n const result = await fitReference(root, platform, adId);\n if (!result.ok) {\n writeJson({ ok: false, error: result.error });\n process.exit(1);\n }\n const fit = result.fit;\n const why = [fit.why_it_wins.disguise, fit.why_it_wins.trigger, fit.why_it_wins.logic].filter(Boolean).join(\"; \");\n writeJson({\n ok: true,\n data: {\n ad_id: adId,\n verdict: fit.verdict,\n why_it_wins: why,\n load_bearing: fit.load_bearing.map((l) => ({\n element: l.element,\n ...(l.job ? { job: l.job } : {}),\n decision: decisionOf(l),\n ...(l.ours ? { ours: l.ours } : {}),\n ...(l.rule ? { rule: l.rule } : {}),\n })),\n ...(fit.brand_presence ? { brand_presence: fit.brand_presence } : {}),\n ...(fit.carry ? { carry: fit.carry } : {}),\n ...(args.full ? { read: fit } : {}),\n },\n hints: fitHints(fit, adId, platform, memeRegister(await readCompanyReading(root).catch(() => null))),\n });\n },\n});\n","import type { AdContent, AdContentResponse } from \"@baker/api/ad-library\";\nimport { apiGet } from \"../../client.ts\";\n\n/**\n * The winners library's structured read of the reference ad, carried into the scaffold by id.\n *\n * Before this, the reference reached `scaffold-static-ad` as a picture plus free text, and the\n * describe pass re-read from pixels what ad-dna had already extracted: the container\n * (`format_pattern`), the composition, the persuasion mechanism, the offer, every text block\n * with its role. That read is fetched here the way `baker winning-ads content <adId> --full`\n * fetches it, projected to what the render can act on, and written into `prompt.json` as\n * `reference`, so the agent and the render prompt read one account of why the ad won.\n */\n\n/** The platforms the library indexes: the `sourcePlatform` enum of the scaffold's creatives collection. */\nexport const LIBRARY_PLATFORMS = [\"meta\", \"linkedin\", \"tiktok\", \"google\"] as const;\nexport type LibraryPlatform = (typeof LIBRARY_PLATFORMS)[number];\n\nexport type SourcePlatformResolution = { ok: true; platform: LibraryPlatform } | { ok: false; message: string };\n\n/** `--source-platform`, default meta; an unknown value is refused, never mapped to a guess. */\nexport function resolveSourcePlatform(flag: string | undefined): SourcePlatformResolution {\n const value = flag?.trim();\n if (!value) return { ok: true, platform: \"meta\" };\n if ((LIBRARY_PLATFORMS as readonly string[]).includes(value)) return { ok: true, platform: value as LibraryPlatform };\n return {\n ok: false,\n message: `--source-platform \"${value}\" is not a library platform. Use one of: ${LIBRARY_PLATFORMS.join(\", \")}.`,\n };\n}\n\nconst PICK_A_DESIGN =\n \"To build a static on a proven design, pick a Google display ad or a static from another platform (`baker winning-ads search --format static`); a YouTube ad is a video reference, read with `baker winning-ads content`.\";\n\n/** Why an ad cannot be built on: what the agent reads it for instead. */\nexport type DesignRefusal = { code: \"NOT_A_DESIGN_REFERENCE\"; message: string; fix: string };\n\n/** What a reference is judged on: its format and, on Google, which kind of ad it is. */\nexport type ReferenceKind = Pick<AdContent, \"format\"> & Partial<Pick<AdContent, \"google_ad_type\">>;\n\n/**\n * Why a library ad is no design to build on, else null. Only Google's display (image) and YouTube\n * (video) ads are: a search ad is words, and a Shopping listing or an app-install ad is assembled by\n * Google from a feed or a store page. An ad whose kind the library does not say is judged by its\n * format alone. Pure.\n */\nexport function notADesignReference(\n platform: LibraryPlatform,\n adId: string,\n ad: ReferenceKind,\n): DesignRefusal | null {\n if (platform !== \"google\") return null;\n if (ad.format === \"text\" || ad.google_ad_type === \"search\") {\n return {\n code: \"NOT_A_DESIGN_REFERENCE\",\n message: `Google ad ${adId} is a search text ad: a reference for wording, not a design.`,\n fix: `Read it with \\`baker winning-ads content ${adId} --platform google\\` and write our own copy. ${PICK_A_DESIGN}`,\n };\n }\n const assembled =\n ad.google_ad_type === \"shopping\"\n ? \"a Shopping product listing, which Google builds from a product feed\"\n : ad.google_ad_type === \"app\"\n ? \"an app-install ad, which Google builds from the app's store page\"\n : null;\n if (assembled) {\n return {\n code: \"NOT_A_DESIGN_REFERENCE\",\n message: `Google ad ${adId} is ${assembled}: there is no design of the advertiser's to build on.`,\n fix: PICK_A_DESIGN,\n };\n }\n return null;\n}\n\nexport type ReferenceTextBlock = { text: string; role?: string; position?: string };\n\n/** The `reference` block `prompt.json` carries: the library's read of the source ad, filled fields only. */\nexport type LibraryReference = {\n ad_id: string;\n platform: LibraryPlatform;\n advertiser?: string;\n advertiser_id?: string;\n format_pattern?: string;\n layout: Record<string, unknown>;\n message: Record<string, unknown>;\n offer: Record<string, unknown>;\n text_blocks: ReferenceTextBlock[];\n copy: Record<string, unknown>;\n};\n\n/** Fetch one ad's content as `baker winning-ads content --full` does. Throws on any failure; the caller degrades. */\nexport async function fetchLibraryReference(adId: string, platform: LibraryPlatform): Promise<AdContent> {\n const data = await apiGet<AdContentResponse>(\"/api/ad-library/ad-content\", { id: adId, platform });\n if (!data?.ad) throw new Error(`the library returned no ad for ${adId} on ${platform}`);\n return data.ad;\n}\n\n/** Only what the library found: null, undefined and empty lists are absences, never findings. */\nfunction filled(entries: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(entries).filter(([, v]) => v !== null && v !== undefined && !(Array.isArray(v) && v.length === 0)),\n );\n}\n\n/** Project the library's ad content to the block the blueprint and the render prompt read. */\nexport function libraryReferenceBlock(\n ad: AdContent,\n ids: { adId: string; platform: LibraryPlatform; advertiserId: string | undefined },\n): LibraryReference {\n const textBlocks: ReferenceTextBlock[] = ad.on_screen_text.flatMap((o) =>\n o.text\n ? [{ text: o.text, ...(o.role ? { role: o.role } : {}), ...(o.position ? { position: o.position } : {}) }]\n : [],\n );\n const advertiser = ad.advertiser ?? undefined;\n const advertiserId = ids.advertiserId ?? ad.advertiser_id ?? undefined;\n return {\n ad_id: ids.adId,\n platform: ids.platform,\n ...(advertiser ? { advertiser } : {}),\n ...(advertiserId ? { advertiser_id: advertiserId } : {}),\n ...(ad.layout.format_pattern ? { format_pattern: ad.layout.format_pattern } : {}),\n layout: filled({\n composition: ad.layout.composition,\n focal_subject: ad.layout.focal_subject,\n aspect_ratio: ad.layout.aspect_ratio,\n background: ad.layout.background,\n palette_mood: ad.layout.palette_mood,\n colors: ad.layout.colors,\n production: ad.layout.production,\n aesthetic: ad.layout.aesthetic,\n cta_in_image: ad.layout.cta_in_image,\n markers: ad.layout.markers,\n }),\n message: filled({\n mechanism: ad.message.mechanism,\n awareness: ad.message.awareness_stage,\n sophistication: ad.message.sophistication,\n angle: ad.angle,\n hook_archetype: ad.hook_archetype,\n pain_points: ad.message.pain_points,\n desires: ad.message.desires,\n value_props: ad.message.value_props,\n objections_handled: ad.message.objections_handled,\n proof: ad.message.proof,\n risk_reversal: ad.message.risk_reversal,\n }),\n offer: filled({\n offer_type: ad.offer.offer_type,\n pricing_model: ad.offer.pricing_model,\n entry_price: ad.offer.entry_price,\n no_credit_card: ad.offer.no_credit_card,\n guarantee: ad.offer.guarantee,\n guarantee_days: ad.offer.guarantee_days,\n urgency: ad.offer.urgency,\n bonus: ad.offer.bonus,\n }),\n text_blocks: textBlocks,\n copy: filled({ primary_text: ad.primary_text, headline: ad.headline, cta: ad.cta }),\n };\n}\n\n/**\n * The `context` the describe pass gets: the agent's own provenance plus what the library\n * already read off this ad. The describe pass still reads the pixels (the layout grid, the\n * fonts, the expressions), but it is told the container, the mechanism and the words up front\n * so its blueprint and the library's read cannot disagree on what the ad is.\n */\nexport function referenceDescribeContext(\n reference: LibraryReference | undefined,\n agentContext: string | undefined,\n): string | undefined {\n const own = agentContext?.trim() || undefined;\n if (!reference) return own;\n const facts: string[] = [];\n if (reference.advertiser) facts.push(`advertiser: ${reference.advertiser}`);\n if (reference.format_pattern) facts.push(`container (format_pattern): ${reference.format_pattern}`);\n if (typeof reference.layout.composition === \"string\") facts.push(`composition: ${reference.layout.composition}`);\n if (typeof reference.message.mechanism === \"string\") facts.push(`persuasion mechanism: ${reference.message.mechanism}`);\n if (typeof reference.message.awareness === \"string\") facts.push(`awareness stage: ${reference.message.awareness}`);\n if (typeof reference.offer.offer_type === \"string\") facts.push(`offer: ${reference.offer.offer_type}`);\n if (reference.text_blocks.length > 0) {\n facts.push(\n `text blocks: ${reference.text_blocks.map((b) => `\"${b.text}\"${b.role ? ` (${b.role})` : \"\"}`).join(\"; \")}`,\n );\n }\n const library =\n `The ads library has already read this ad: ${facts.join(\". \")}. ` +\n \"Your blueprint must agree with it on the container and the mechanism; refine and detail them, never contradict them, and transcribe the text blocks exactly.\";\n return own ? `${own}. ${library}` : library;\n}\n\n/**\n * Write the library's read into the blueprint as `reference`. Never a mechanism: the library's\n * container and persuasion label (\"comparison_table container carrying us_vs_them\") name the\n * format, not why the ad won, and seeded as the mechanism they hid that the read found none\n * (audited Sept 2026). Why it wins is `baker winning-ads fit`'s to say.\n */\nexport function mergeReferenceIntoBlueprint(blueprint: unknown, reference: LibraryReference | undefined): unknown {\n if (!reference || !blueprint || typeof blueprint !== \"object\" || Array.isArray(blueprint)) return blueprint;\n return { ...(blueprint as Record<string, unknown>), reference };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAiB3B,SAAS,OAAO,SAAS,UAAU,iBAAiB;AACpD,OAAO,UAAU;AAGjB,SAAS,qBAAqB;AAC9B,OAAO,WAAW;AAClB,SAAS,SAAS;;;ACRX,IAAM,oBAAoB,CAAC,QAAQ,YAAY,UAAU,QAAQ;AAMjE,SAAS,sBAAsB,MAAoD;AACxF,QAAM,QAAQ,MAAM,KAAK;AACzB,MAAI,CAAC,MAAO,QAAO,EAAE,IAAI,MAAM,UAAU,OAAO;AAChD,MAAK,kBAAwC,SAAS,KAAK,EAAG,QAAO,EAAE,IAAI,MAAM,UAAU,MAAyB;AACpH,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,SAAS,sBAAsB,KAAK,4CAA4C,kBAAkB,KAAK,IAAI,CAAC;AAAA,EAC9G;AACF;A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