@koda-sl/baker-cli 0.868.0-dev.009dcef7a → 0.868.0-dev.5be0a9a76

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 (30) hide show
  1. package/README.md +3 -4
  2. package/dist/{add-ZMOFKHFR.js → add-TKHBYZF6.js} +2 -2
  3. package/dist/{ads-66KVUF35.js → ads-U33JFGCR.js} +3 -3
  4. package/dist/{chunk-LJO3I2W2.js → chunk-BPIHAIWB.js} +11 -20
  5. package/dist/chunk-BPIHAIWB.js.map +1 -0
  6. package/dist/{chunk-MIIY3MVK.js → chunk-TY4MTOTL.js} +22 -1
  7. package/dist/chunk-TY4MTOTL.js.map +1 -0
  8. package/dist/cli.js +3 -3
  9. package/dist/cli.js.map +1 -1
  10. package/dist/{flows-PP6BRBD7.js → flows-FRWZWHXZ.js} +3 -3
  11. package/dist/{linkedin-OZGEZLN5.js → linkedin-EBOTX37R.js} +4 -8
  12. package/dist/{linkedin-OZGEZLN5.js.map → linkedin-EBOTX37R.js.map} +1 -1
  13. package/dist/{meta-C7VHIHDL.js → meta-SPPSYRMC.js} +2 -2
  14. package/dist/{preview-25YWCQBJ.js → preview-4GUQGDBD.js} +47 -130
  15. package/dist/preview-4GUQGDBD.js.map +1 -0
  16. package/dist/preview-HD3QAR53.js +104 -0
  17. package/dist/preview-HD3QAR53.js.map +1 -0
  18. package/dist/{tags-IQ6BCRLE.js → tags-DFCLKJX7.js} +26 -15
  19. package/dist/tags-DFCLKJX7.js.map +1 -0
  20. package/package.json +1 -1
  21. package/dist/chunk-LJO3I2W2.js.map +0 -1
  22. package/dist/chunk-MIIY3MVK.js.map +0 -1
  23. package/dist/preview-25YWCQBJ.js.map +0 -1
  24. package/dist/preview-TTIHEWK6.js +0 -147
  25. package/dist/preview-TTIHEWK6.js.map +0 -1
  26. package/dist/tags-IQ6BCRLE.js.map +0 -1
  27. /package/dist/{add-ZMOFKHFR.js.map → add-TKHBYZF6.js.map} +0 -0
  28. /package/dist/{ads-66KVUF35.js.map → ads-U33JFGCR.js.map} +0 -0
  29. /package/dist/{flows-PP6BRBD7.js.map → flows-FRWZWHXZ.js.map} +0 -0
  30. /package/dist/{meta-C7VHIHDL.js.map → meta-SPPSYRMC.js.map} +0 -0
package/README.md CHANGED
@@ -339,7 +339,7 @@ Use `--output` to change format:
339
339
  | `csv` | RFC 4180 comma-separated values | Analysis tools | `baker research …` only |
340
340
  | `jsonl` | One JSON object per line | Streaming/appending | `baker research …` only |
341
341
 
342
- `--output json` is accepted even by a command that declares no `--output`: the envelope is already what it prints, and on a command whose default is a readable view (`baker tags list`, the `draft` commands) it becomes that command's `--json`. `baker canvas run` always prints its envelope alone on stdout and its progress lines on stderr — or, when stderr is not a terminal, in a log of its own (`canvas/.cache/logs/<slug>-<n>.log`), with only a `[log]` line naming it and its `[warn]`, `[autofix]` and `[viewer]` lines (each once, on one line) left on stderr, and a run that crashes still printing why as its envelope — so it takes it as already done; on `baker creatives publish`, whose own `--output` names the cover size, `--output json` is the envelope request and the cover keeps any other `--output` value. The few commands that print only text — `baker analytics sending-events`, `baker canvas sync-definition` — refuse it, as a command without its own `--output` refuses `files`. A bare `--json` is taken the same way: where the envelope is already the output (every family's `draft show`, `chats list`) it is dropped, and a command that declares `--json` keeps it. Every `draft` group lists when no subcommand is named (`baker ads google draft`, `baker ga4 draft`, `baker shopify draft`).
342
+ `--output json` is accepted even by a command that declares no `--output`: the envelope is already what it prints, and on a command whose default is a readable view (the `draft` commands) it becomes that command's `--json`. `baker canvas run` always prints its envelope alone on stdout and its progress lines on stderr — or, when stderr is not a terminal, in a log of its own (`canvas/.cache/logs/<slug>-<n>.log`), with only a `[log]` line naming it and its `[warn]`, `[autofix]` and `[viewer]` lines (each once, on one line) left on stderr, and a run that crashes still printing why as its envelope — so it takes it as already done; on `baker creatives publish`, whose own `--output` names the cover size, `--output json` is the envelope request and the cover keeps any other `--output` value. The few commands that print only text — `baker analytics sending-events`, `baker canvas sync-definition` — refuse it, as a command without its own `--output` refuses `files`. A bare `--json` is taken the same way: where the envelope is already the output (every family's `draft show`, `chats list`) it is dropped, and a command that declares `--json` keeps it. Every `draft` group lists when no subcommand is named (`baker ads google draft`, `baker ga4 draft`, `baker shopify draft`).
343
343
 
344
344
  `--format <f>` is read as `--output <f>` (`--format table` as `--output md`) on any command without a `--format` of its own (`ads google ads create`, `images screenshot` keep theirs). A shared option written with no value (`--fields`, `--out`, `--output`) is refused as needing one, not as an unknown option.
345
345
 
@@ -1491,7 +1491,6 @@ baker ads meta insights --object 9988 --level ad --intent video \
1491
1491
  --breakdowns publisher_platform,platform_position --date-preset last_30d # one ad only: hints flag placements playing far below the ad's own rate
1492
1492
  baker ads meta preview --creative-id 9988 --placement facebook_reels_overlay --platform facebook
1493
1493
  baker ads meta preview --list-formats # ad_format values + placement mappings
1494
- baker ads meta preview --creative-id 9988,9989 --ad-format MOBILE_FEED_STANDARD,INSTAGRAM_REELS # every creative × format pair in one call, drawn in parallel (at most 24)
1495
1494
  baker ads meta videos --ad-id 9988,9989 # download the ads' video files (MP4) to /tmp/meta-ad-videos; --url-only for the addresses
1496
1495
 
1497
1496
  # "What audience is this targeting?"
@@ -1817,7 +1816,6 @@ baker ads linkedin campaigns --account-id 503001492 --targeting
1817
1816
  # "What does this ad actually show?" — LinkedIn's own feed rendering, desktop + mobile:
1818
1817
  # data.previews[].shownText (the text displayed, in order) and .image (a picture)
1819
1818
  baker ads linkedin preview 1611562694 --account-id 503001492
1820
- baker ads linkedin preview 1611562694 1611562695 --placement mobile # several ads in one call, drawn in parallel
1821
1819
 
1822
1820
  # "Top companies seeing this campaign" (ABM feedback loop) — org names auto-resolved
1823
1821
  baker ads linkedin top-companies --campaign-id 1234 --last-days 30
@@ -4914,7 +4912,8 @@ Read the client's marketing/analytics tags (Meta pixel, ChatGPT Ads pixel, GA4,
4914
4912
  `BAKER_CHAT_ID` must be set.
4915
4913
 
4916
4914
  ```bash
4917
- baker tags list # effective view: production + staged, full readable config + secret status
4915
+ baker tags list # effective view as the JSON envelope: production + staged, config + secret status
4916
+ baker tags list --output md --full # readable, with custom code scripts whole (by default shown by size)
4918
4917
  baker tags draft # review the staged changes awaiting publish
4919
4918
  baker tags unstage tag_temp_abc123 # take back one change this chat staged (or --all)
4920
4919
  ```
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  failApi
3
- } from "./chunk-MIIY3MVK.js";
3
+ } from "./chunk-TY4MTOTL.js";
4
4
  import {
5
5
  rebindReference
6
6
  } from "./chunk-YUZGTNAO.js";
@@ -660,4 +660,4 @@ export {
660
660
  secondPixelHint,
661
661
  stepNameRefusal
662
662
  };
663
- //# sourceMappingURL=add-ZMOFKHFR.js.map
663
+ //# sourceMappingURL=add-TKHBYZF6.js.map
@@ -34,8 +34,8 @@ Full guides: __tooling__/docs/tools/baker/ads-<platform>.md (google|meta|linkedi
34
34
  },
35
35
  subCommands: {
36
36
  google: () => import("./google-HHKFDH7I.js").then((m) => m.googleCommand),
37
- meta: () => import("./meta-C7VHIHDL.js").then((m) => m.metaCommand),
38
- linkedin: () => import("./linkedin-OZGEZLN5.js").then((m) => m.linkedinCommand),
37
+ meta: () => import("./meta-SPPSYRMC.js").then((m) => m.metaCommand),
38
+ linkedin: () => import("./linkedin-EBOTX37R.js").then((m) => m.linkedinCommand),
39
39
  x: () => import("./x-JU6LF2MM.js").then((m) => m.xCommand),
40
40
  chatgpt: () => import("./chatgpt-FV4PVN4W.js").then((m) => m.chatgptCommand),
41
41
  performance: () => import("./performance-Y2S5FDGI.js").then((m) => m.performanceCommand),
@@ -45,4 +45,4 @@ Full guides: __tooling__/docs/tools/baker/ads-<platform>.md (google|meta|linkedi
45
45
  export {
46
46
  adsCommand
47
47
  };
48
- //# sourceMappingURL=ads-66KVUF35.js.map
48
+ //# sourceMappingURL=ads-U33JFGCR.js.map
@@ -8,32 +8,23 @@ import { tmpdir } from "os";
8
8
  import { join } from "path";
9
9
  var AD_PREVIEW_DIR = join(tmpdir(), "baker-ad-previews");
10
10
  var AD_PREVIEW_DIR_LABEL = "your system temp folder, under baker-ad-previews";
11
- var DRAW_CONCURRENCY = 4;
12
11
  async function renderAdPreviews(inputs, target, draw = drawPreviewInChromium) {
13
12
  mkdirSync(target.dir, { recursive: true });
13
+ const previews = [];
14
14
  const taken = /* @__PURE__ */ new Map();
15
- const jobs = inputs.map((input) => {
15
+ for (const input of inputs) {
16
16
  const where = input.surface ? { placement: input.placement, surface: input.surface } : { placement: input.placement };
17
- const base = [input.name ?? target.name, input.placement, input.surface?.toLowerCase()].filter(Boolean).join("-");
17
+ const base = [target.name, input.placement, input.surface?.toLowerCase()].filter(Boolean).join("-");
18
18
  const seen = (taken.get(base) ?? 0) + 1;
19
19
  taken.set(base, seen);
20
- return { where, html: input.html, file: join(target.dir, `${seen > 1 ? `${base}-${seen}` : base}.png`) };
21
- });
22
- const previews = new Array(jobs.length);
23
- let next = 0;
24
- const worker = async () => {
25
- while (next < jobs.length) {
26
- const index = next++;
27
- const { where, html, file } = jobs[index];
28
- try {
29
- const { text } = await draw(html, file);
30
- previews[index] = { ...where, shownText: shownLines(text), image: file };
31
- } catch (err) {
32
- previews[index] = { ...where, error: err instanceof Error ? err.message : String(err) };
33
- }
20
+ const file = join(target.dir, `${seen > 1 ? `${base}-${seen}` : base}.png`);
21
+ try {
22
+ const { text } = await draw(input.html, file);
23
+ previews.push({ ...where, shownText: shownLines(text), image: file });
24
+ } catch (err) {
25
+ previews.push({ ...where, error: err instanceof Error ? err.message : String(err) });
34
26
  }
35
- };
36
- await Promise.all(Array.from({ length: Math.min(DRAW_CONCURRENCY, jobs.length) }, worker));
27
+ }
37
28
  return { previews, hints: previewHints(previews) };
38
29
  }
39
30
  function shownLines(text) {
@@ -91,4 +82,4 @@ export {
91
82
  AD_PREVIEW_DIR_LABEL,
92
83
  renderAdPreviews
93
84
  };
94
- //# sourceMappingURL=chunk-LJO3I2W2.js.map
85
+ //# sourceMappingURL=chunk-BPIHAIWB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/ads/ad-preview-images.ts"],"sourcesContent":["import { mkdirSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { launchBrowser } from \"../../engine/landing-library/browser.ts\";\n\n/**\n * Opens a platform's preview iframe and returns what it displays: the text\n * people read (`shownText`) and a picture for questions text cannot answer.\n *\n * The API's fields say what is stored, not what shows. A Session paused seven\n * live ads because a stored headline read like an internal code, with no way to\n * check whether the feed showed it. The rendered text settles that; the picture\n * covers what is not text — words drawn into the artwork, cropping, layout.\n */\n\nexport interface AdPreviewInput {\n placement: string;\n /** Where the platform shows it (LinkedIn FEED, …) when one placement renders on several surfaces. */\n surface?: string;\n html: string;\n}\n\ntype AdPreviewWhere = { placement: string; surface?: string };\nexport type AdPreviewResult =\n | (AdPreviewWhere & { shownText: string[]; image: string })\n | (AdPreviewWhere & { error: string });\n\n/** Render `html` (a platform iframe): save a PNG at `file`, return the text it displays. */\nexport type DrawPreview = (html: string, file: string) => Promise<{ text: string }>;\n\nexport const AD_PREVIEW_DIR = join(tmpdir(), \"baker-ad-previews\");\n\n/**\n * The same folder as a sentence, for an arg description.\n *\n * `AD_PREVIEW_DIR` itself must never reach one: it is `tmpdir()` RESOLVED, which is\n * `/tmp/baker-ad-previews` on Linux and `/var/folders/<random>/T/baker-ad-previews` on a Mac — so\n * `catalog:export` wrote whichever machine ran it into `cli-catalog/families/ads-meta.json`, and\n * `catalog.test.ts` then failed for everyone else. The catalog is committed, so a description in it\n * has to be the same on every machine.\n */\nexport const AD_PREVIEW_DIR_LABEL = \"your system temp folder, under baker-ad-previews\";\n\nexport async function renderAdPreviews(\n inputs: readonly AdPreviewInput[],\n target: { dir: string; name: string },\n draw: DrawPreview = drawPreviewInChromium,\n): Promise<{ previews: AdPreviewResult[]; hints: string[] }> {\n mkdirSync(target.dir, { recursive: true });\n const previews: AdPreviewResult[] = [];\n const taken = new Map<string, number>();\n for (const input of inputs) {\n const where: AdPreviewWhere = input.surface\n ? { placement: input.placement, surface: input.surface }\n : { placement: input.placement };\n // One file per rendering: a shared name would leave two results pointing at the last picture drawn.\n const base = [target.name, input.placement, input.surface?.toLowerCase()].filter(Boolean).join(\"-\");\n const seen = (taken.get(base) ?? 0) + 1;\n taken.set(base, seen);\n const file = join(target.dir, `${seen > 1 ? `${base}-${seen}` : base}.png`);\n try {\n const { text } = await draw(input.html, file);\n previews.push({ ...where, shownText: shownLines(text), image: file });\n } catch (err) {\n previews.push({ ...where, error: err instanceof Error ? err.message : String(err) });\n }\n }\n return { previews, hints: previewHints(previews) };\n}\n\nfunction shownLines(text: string): string[] {\n return text\n .split(\"\\n\")\n .map((line) => line.replace(/\\s+/g, \" \").trim())\n .filter(Boolean);\n}\n\nfunction previewHints(previews: readonly AdPreviewResult[]): string[] {\n const hints: string[] = [];\n if (previews.some((p) => \"image\" in p)) {\n hints.push(\n \"shownText is what people see on the ad, in order — rendered by the platform itself, so it settles which text is displayed (headline under the image, button, cut-off intro). The API fields only say what is stored. Words drawn into the artwork are not in shownText: Read the image for those, and for cropping or how the ad looks.\",\n );\n }\n if (previews.some((p) => \"error\" in p)) {\n hints.push(\n \"Some previews could not be drawn. Do not describe how those look — say they could not be checked, and carry on with the rest.\",\n );\n }\n return hints;\n}\n\n/**\n * The platforms' iframes have a fixed window (Meta's 335×450) and scroll the rest,\n * which cuts the headline and button off a picture. The frame is grown to its\n * content's height first, so the picture holds the whole ad.\n */\nexport async function drawPreviewInChromium(html: string, file: string): Promise<{ text: string }> {\n const browser = await launchBrowser();\n try {\n const context = await browser.newContext({ viewport: { width: 900, height: 1200 }, deviceScaleFactor: 2 });\n const page = await context.newPage();\n await page.setContent(`<!doctype html><body style=\"margin:0;background:#fff\">${html}</body>`, {\n waitUntil: \"load\",\n timeout: 30_000,\n });\n await page.waitForLoadState(\"networkidle\", { timeout: 15_000 }).catch(() => undefined);\n const iframe = await page.$(\"iframe\");\n if (!iframe) throw new Error(\"the platform returned no preview frame\");\n const frame = await iframe.contentFrame();\n if (frame) {\n const height = await frame.evaluate(() =>\n Math.max(document.documentElement.scrollHeight, document.body?.scrollHeight ?? 0),\n );\n if (height > 0) {\n await iframe.evaluate((node, h) => {\n node.removeAttribute(\"height\");\n (node as HTMLElement).style.height = `${h}px`;\n }, height);\n await frame.waitForLoadState(\"networkidle\", { timeout: 10_000 }).catch(() => undefined);\n }\n }\n await iframe.screenshot({ path: file });\n // innerText follows the layout: hidden elements drop out, line breaks stay.\n const text = frame ? await frame.evaluate(() => document.body?.innerText ?? \"\") : \"\";\n return { text };\n } finally {\n await browser.close();\n }\n}\n"],"mappings":";;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,YAAY;AA4Bd,IAAM,iBAAiB,KAAK,OAAO,GAAG,mBAAmB;AAWzD,IAAM,uBAAuB;AAEpC,eAAsB,iBACpB,QACA,QACA,OAAoB,uBACuC;AAC3D,YAAU,OAAO,KAAK,EAAE,WAAW,KAAK,CAAC;AACzC,QAAM,WAA8B,CAAC;AACrC,QAAM,QAAQ,oBAAI,IAAoB;AACtC,aAAW,SAAS,QAAQ;AAC1B,UAAM,QAAwB,MAAM,UAChC,EAAE,WAAW,MAAM,WAAW,SAAS,MAAM,QAAQ,IACrD,EAAE,WAAW,MAAM,UAAU;AAEjC,UAAM,OAAO,CAAC,OAAO,MAAM,MAAM,WAAW,MAAM,SAAS,YAAY,CAAC,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAClG,UAAM,QAAQ,MAAM,IAAI,IAAI,KAAK,KAAK;AACtC,UAAM,IAAI,MAAM,IAAI;AACpB,UAAM,OAAO,KAAK,OAAO,KAAK,GAAG,OAAO,IAAI,GAAG,IAAI,IAAI,IAAI,KAAK,IAAI,MAAM;AAC1E,QAAI;AACF,YAAM,EAAE,KAAK,IAAI,MAAM,KAAK,MAAM,MAAM,IAAI;AAC5C,eAAS,KAAK,EAAE,GAAG,OAAO,WAAW,WAAW,IAAI,GAAG,OAAO,KAAK,C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,cAAc,SAAS,MAAM,gBAAgB,CAAC;AAAA,MAClF;AACA,UAAI,SAAS,GAAG;AACd,cAAM,OAAO,SAAS,CAAC,MAAM,MAAM;AACjC,eAAK,gBAAgB,QAAQ;AAC7B,UAAC,KAAqB,MAAM,SAAS,GAAG,CAAC;AAAA,QAC3C,GAAG,MAAM;AACT,cAAM,MAAM,iBAAiB,eAAe,EAAE,SAAS,IAAO,CAAC,EAAE,MAAM,MAAM,MAAS;AAAA,MACxF;AAAA,IACF;AACA,UAAM,OAAO,WAAW,EAAE,MAAM,KAAK,CAAC;AAEtC,UAAM,OAAO,QAAQ,MAAM,MAAM,SAAS,MAAM,SAAS,MAAM,aAAa,EAAE,IAAI;AAClF,WAAO,EAAE,KAAK;AAAA,EAChB,UAAE;AACA,UAAM,QAAQ,MAAM;AAAA,EACtB;AACF;","names":[]}
@@ -28,6 +28,22 @@ function failValidation(message) {
28
28
  function renderConfigValue(value) {
29
29
  return value.includes("\n") ? value.replace(/\n/g, "\n ") : value;
30
30
  }
31
+ var LONG_VALUE_CHARS = 200;
32
+ function sizeOf(value) {
33
+ const lines = value.split("\n").length;
34
+ return `${lines} ${lines === 1 ? "line" : "lines"}, ${value.length} chars`;
35
+ }
36
+ function listedTag(entry) {
37
+ const long = Object.entries(entry.config).filter(
38
+ ([, value]) => value.includes("\n") || value.length > LONG_VALUE_CHARS
39
+ );
40
+ if (long.length === 0) {
41
+ return entry;
42
+ }
43
+ const config = Object.fromEntries(Object.entries(entry.config).filter(([key]) => !long.some(([k]) => k === key)));
44
+ return { ...entry, config, collapsed: Object.fromEntries(long.map(([key, value]) => [key, sizeOf(value)])) };
45
+ }
46
+ var COLLAPSED_HINT = "A long config value (a custom `code` script) shows as its size under `collapsed`; `baker tags list --full` prints it whole, to reuse in a follow-up change.";
31
47
  function renderEffectiveEntry(entry) {
32
48
  const parts = [entry.ref, entry.type];
33
49
  if (entry.identifier !== void 0) {
@@ -46,6 +62,9 @@ function renderEffectiveEntry(entry) {
46
62
  const header = parts.join(" ");
47
63
  const identifyingField = TAG_IDENTIFYING_FIELD[entry.type];
48
64
  const configLines = Object.entries(entry.config).filter(([key]) => key !== identifyingField).map(([key, value]) => ` ${key}: ${renderConfigValue(value)}`);
65
+ for (const [key, size] of Object.entries(entry.collapsed ?? {})) {
66
+ configLines.push(` ${key}: (${size} \u2014 --full prints it)`);
67
+ }
49
68
  return configLines.length > 0 ? `${header}
50
69
  ${configLines.join("\n")}` : header;
51
70
  }
@@ -59,7 +78,9 @@ function tagsListHints() {
59
78
  export {
60
79
  failApi,
61
80
  failValidation,
81
+ listedTag,
82
+ COLLAPSED_HINT,
62
83
  renderEffectiveEntry,
63
84
  tagsListHints
64
85
  };
65
- //# sourceMappingURL=chunk-MIIY3MVK.js.map
86
+ //# sourceMappingURL=chunk-TY4MTOTL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/tags/shared.ts"],"sourcesContent":["import { TAG_IDENTIFYING_FIELD, type TagsEffectiveEntry } from \"@baker/api\";\nimport { ApiError } from \"../../client.ts\";\nimport { writeJson } from \"../../output.ts\";\n\nexport function failApi(err: unknown): never {\n if (err instanceof ApiError) {\n writeJson({ ok: false, error: { code: err.code, message: err.message } });\n process.exit(1);\n }\n if (err instanceof Error) {\n writeJson({ ok: false, error: { code: \"INTERNAL_ERROR\", message: err.message } });\n process.exit(1);\n }\n writeJson({ ok: false, error: { code: \"INTERNAL_ERROR\", message: \"Unexpected error\" } });\n process.exit(1);\n}\n\nexport function failValidation(message: string): never {\n writeJson({ ok: false, error: { code: \"VALIDATION_ERROR\", message } });\n process.exit(1);\n}\n\n/** Indent a possibly multi-line config value so long snippets (the `code` tag) stay readable. */\nfunction renderConfigValue(value: string): string {\n return value.includes(\"\\n\") ? value.replace(/\\n/g, \"\\n \") : value;\n}\n\n/** A config value longer than this, or on more than one line, is a script: shown by its size unless `--full`. */\nconst LONG_VALUE_CHARS = 200;\n\n/** A listed tag, its scripts shown by size so one custom `code` body does not bury the other tags. */\nexport type ListedTag = TagsEffectiveEntry & { collapsed?: Record<string, string> };\n\nfunction sizeOf(value: string): string {\n const lines = value.split(\"\\n\").length;\n return `${lines} ${lines === 1 ? \"line\" : \"lines\"}, ${value.length} chars`;\n}\n\n/** `entry` with each long config value moved to `collapsed` as its size; `--full` keeps it whole. */\nexport function listedTag(entry: TagsEffectiveEntry): ListedTag {\n const long = Object.entries(entry.config).filter(\n ([, value]) => value.includes(\"\\n\") || value.length > LONG_VALUE_CHARS,\n );\n if (long.length === 0) {\n return entry;\n }\n const config = Object.fromEntries(Object.entries(entry.config).filter(([key]) => !long.some(([k]) => k === key)));\n return { ...entry, config, collapsed: Object.fromEntries(long.map(([key, value]) => [key, sizeOf(value)])) };\n}\n\nexport const COLLAPSED_HINT =\n \"A long config value (a custom `code` script) shows as its size under `collapsed`; `baker tags list --full` prints it whole, to reuse in a follow-up change.\";\n\nexport function renderEffectiveEntry(entry: ListedTag): string {\n const parts = [entry.ref, entry.type];\n if (entry.identifier !== undefined) {\n parts.push(entry.identifier);\n }\n if (entry.staged !== undefined) {\n parts.push(`[staged: ${entry.staged}]`);\n }\n const secretBits = [\n ...entry.secretsSet.map((field) => `${field} ✓ set`),\n ...entry.secretsPending.map((field) => `${field} ⏳ pending`),\n ];\n if (secretBits.length > 0) {\n parts.push(`[secrets: ${secretBits.join(\", \")}]`);\n }\n const header = parts.join(\" \");\n // All config values here are already redacted server-side (secrets stripped),\n // so every field printed is safe to read and reuse to pre-fill a follow-up\n // change instead of asking the user for a value we store.\n // Skip the identifying field — it's already on the header line as `identifier`.\n const identifyingField = TAG_IDENTIFYING_FIELD[entry.type];\n const configLines = Object.entries(entry.config)\n .filter(([key]) => key !== identifyingField)\n .map(([key, value]) => ` ${key}: ${renderConfigValue(value)}`);\n for (const [key, size] of Object.entries(entry.collapsed ?? {})) {\n configLines.push(` ${key}: (${size} — --full prints it)`);\n }\n return configLines.length > 0 ? `${header}\\n${configLines.join(\"\\n\")}` : header;\n}\n\n/**\n * The write path, restated on every read.\n *\n * This family is read-only, so `list` is where a chat decides what to do about\n * a tag — and a production chat decided, from its tool list alone, that the\n * approval form did not exist, never called it, and filed the change as a Task\n * the user had to carry out by hand. The form is attached to every turn\n * (`baker_ui` rides along on each query), so \"it isn't there\" is a conclusion\n * only a failed call may reach.\n */\nexport function tagsListHints(): string[] {\n return [\n \"To create, edit or delete a tag, call the `request_tag_input` approval form (tool `mcp__baker_ui__request_tag_input`, server `baker_ui`) — it is attached to every turn of this chat and collects any secret values itself.\",\n \"Don't conclude the form is unavailable from your tool list: call it, and report what it returns. And never file a tag change as a Task — a Task hands the user work this chat can stage in one call.\",\n ];\n}\n"],"mappings":";;;;;;;;;;;AAIO,SAAS,QAAQ,KAAqB;AAC3C,MAAI,eAAe,UAAU;AAC3B,cAAU,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,EAAE,CAAC;AACxE,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,MAAI,eAAe,OAAO;AACxB,cAAU,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,kBAAkB,SAAS,IAAI,QAAQ,EAAE,CAAC;AAChF,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,YAAU,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,kBAAkB,SAAS,mBAAmB,EAAE,CAAC;AACvF,UAAQ,KAAK,CAAC;AAChB;AAEO,SAAS,eAAe,SAAwB;AACrD,YAAU,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,oBAAoB,QAAQ,EAAE,CAAC;AACrE,UAAQ,KAAK,CAAC;AAChB;AAGA,SAAS,kBAAkB,OAAuB;AAChD,SAAO,MAAM,SAAS,IAAI,IAAI,MAAM,QAAQ,OAAO,UAAU,IAAI;AACnE;AAGA,IAAM,mBAAmB;AAKzB,SAAS,OAAO,OAAuB;AACrC,QAAM,QAAQ,MAAM,MAAM,IAAI,EAAE;AAChC,SAAO,GAAG,KAAK,IAAI,UAAU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AG,MAAM,QAAQ,gBAAgB,EAC1C,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,OAAO,GAAG,KAAK,kBAAkB,KAAK,CAAC,EAAE;AAClE,aAAW,CAAC,KAAK,IAAI,KAAK,OAAO,QAAQ,MAAM,aAAa,CAAC,CAAC,GAAG;AAC/D,gBAAY,KAAK,OAAO,GAAG,MAAM,IAAI,2BAAsB;AAAA,EAC7D;AACA,SAAO,YAAY,SAAS,IAAI,GAAG,MAAM;AAAA,EAAK,YAAY,KAAK,IAAI,CAAC,KAAK;AAC3E;AAYO,SAAS,gBAA0B;AACxC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
package/dist/cli.js CHANGED
@@ -625,7 +625,7 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`
625
625
  capabilities: () => import("./capabilities-FJAYWDY6.js").then((m) => m.capabilitiesCommand),
626
626
  actions: () => import("./actions-PO35WQVS.js").then((m) => m.actionsCommand),
627
627
  "scheduled-agents": () => import("./scheduled-agents-4UNG26CX.js").then((m) => m.scheduledAgentsCommand),
628
- ads: () => import("./ads-66KVUF35.js").then((m) => m.adsCommand),
628
+ ads: () => import("./ads-U33JFGCR.js").then((m) => m.adsCommand),
629
629
  brand: () => import("./brand-ARJMSWJA.js").then((m) => m.brandCommand),
630
630
  analytics: () => import("./analytics-EM4NNEG5.js").then((m) => m.analyticsCommand),
631
631
  experiment: () => import("./experiment-KOCG7PPI.js").then((m) => m.experimentCommand),
@@ -638,7 +638,7 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`
638
638
  creatives: () => import("./creatives-EWTMQK7H.js").then((m) => m.creativesCommand),
639
639
  rules: () => import("./rules-EPNUXMHG.js").then((m) => m.rulesCommand),
640
640
  files: () => import("./files-4BWOK6EW.js").then((m) => m.filesCommand),
641
- flows: () => import("./flows-PP6BRBD7.js").then((m) => m.flowsCommand),
641
+ flows: () => import("./flows-FRWZWHXZ.js").then((m) => m.flowsCommand),
642
642
  funnel: () => import("./funnel-BFVSY5A6.js").then((m) => m.funnelCommand),
643
643
  images: () => import("./images-R3EK4BDH.js").then((m) => m.imagesCommand),
644
644
  studio: () => import("./studio-VU7CEAEU.js").then((m) => m.studioCommand),
@@ -647,7 +647,7 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`
647
647
  videos: () => import("./videos-FG64T3XK.js").then((m) => m.videosCommand),
648
648
  testimonials: () => import("./testimonials-UCVT5VQY.js").then((m) => m.testimonialsCommand),
649
649
  canvas: () => import("./canvas-NJV6RSX3.js").then((m) => m.canvasCommand),
650
- tags: () => import("./tags-IQ6BCRLE.js").then((m) => m.tagsCommand),
650
+ tags: () => import("./tags-DFCLKJX7.js").then((m) => m.tagsCommand),
651
651
  "tag-manager": () => import("./tag-manager-UJDARCXH.js").then((m) => m.tagManagerCommand),
652
652
  chats: () => import("./chats-65GTXYEC.js").then((m) => m.chatsCommand),
653
653
  history: () => import("./history-K5ULNTEM.js").then((m) => m.historyCommand),