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

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 (71) hide show
  1. package/README.md +5 -3
  2. package/dist/{account-assets-L6BX4YUQ.js → account-assets-4EFV6A2D.js} +6 -6
  3. package/dist/{account-level-OX34JQ7C.js → account-level-7UOXIAB7.js} +3 -3
  4. package/dist/{add-TKHBYZF6.js → add-ZMOFKHFR.js} +2 -2
  5. package/dist/{ads-U33JFGCR.js → ads-B4HSLQMP.js} +2 -2
  6. package/dist/{ads-ZR5D7BZT.js → ads-FQKWQBVZ.js} +10 -10
  7. package/dist/{adsets-3NIYL2GQ.js → adsets-BG3KZ53Y.js} +9 -9
  8. package/dist/{asset-writes-5ZKZDPQ4.js → asset-writes-55AP6IJM.js} +3 -3
  9. package/dist/{audience-writes-NL6NRLLY.js → audience-writes-USX37PPI.js} +2 -2
  10. package/dist/{audiences-DL267GNQ.js → audiences-G4GJZUIT.js} +6 -6
  11. package/dist/{campaigns-RXDC5FSQ.js → campaigns-DNA7TN2T.js} +9 -9
  12. package/dist/{catalogs-QAZ7ZZ5R.js → catalogs-7AG7YVMI.js} +2 -2
  13. package/dist/{chunk-OMJ7DVFJ.js → chunk-ATVUGOXL.js} +5 -4
  14. package/dist/{chunk-OMJ7DVFJ.js.map → chunk-ATVUGOXL.js.map} +1 -1
  15. package/dist/{chunk-UE5ZFTDL.js → chunk-J43KP5NE.js} +2 -2
  16. package/dist/{chunk-TY4MTOTL.js → chunk-MIIY3MVK.js} +1 -22
  17. package/dist/chunk-MIIY3MVK.js.map +1 -0
  18. package/dist/{chunk-EGM42UKF.js → chunk-SXKBGTX2.js} +2 -2
  19. package/dist/cli.js +3 -3
  20. package/dist/cli.js.map +1 -1
  21. package/dist/{copy-writes-QYN6PBU2.js → copy-writes-NJSSVTGB.js} +3 -3
  22. package/dist/{creatives-CPLH3KHQ.js → creatives-4AD65R3V.js} +4 -4
  23. package/dist/{custom-conversions-CTJVAZKC.js → custom-conversions-BDXRIYJW.js} +4 -4
  24. package/dist/{draft-UU3F2VMJ.js → draft-ZUM2WKWP.js} +203 -8
  25. package/dist/draft-ZUM2WKWP.js.map +1 -0
  26. package/dist/{flows-FRWZWHXZ.js → flows-PP6BRBD7.js} +3 -3
  27. package/dist/{instant-experiences-EJWYFWDT.js → instant-experiences-JBN26DUT.js} +2 -2
  28. package/dist/{leads-FEEWX7OO.js → leads-YWURF6YR.js} +2 -2
  29. package/dist/{media-PUOLJUN3.js → media-BITGRDCO.js} +3 -3
  30. package/dist/{meta-SPPSYRMC.js → meta-MY2CIGLA.js} +30 -30
  31. package/dist/{page-photos-ZBMJLL5V.js → page-photos-ZP7APYIE.js} +2 -2
  32. package/dist/{rule-writes-6XP7G35U.js → rule-writes-GE5URXYA.js} +2 -2
  33. package/dist/{rules-BRULCGRV.js → rules-6O5ALFJD.js} +7 -7
  34. package/dist/{studies-357M2C2K.js → studies-LZ4RWESW.js} +5 -5
  35. package/dist/{study-writes-HXUQRPIK.js → study-writes-3WXJDSDU.js} +2 -2
  36. package/dist/{tags-DFCLKJX7.js → tags-IQ6BCRLE.js} +15 -26
  37. package/dist/tags-IQ6BCRLE.js.map +1 -0
  38. package/dist/{targeting-7T7XHBIX.js → targeting-DEM7YHWM.js} +2 -2
  39. package/dist/{write-commands-4KI6T2NF.js → write-commands-EQU4U746.js} +4 -4
  40. package/package.json +1 -1
  41. package/dist/chunk-TY4MTOTL.js.map +0 -1
  42. package/dist/draft-UU3F2VMJ.js.map +0 -1
  43. package/dist/tags-DFCLKJX7.js.map +0 -1
  44. /package/dist/{account-assets-L6BX4YUQ.js.map → account-assets-4EFV6A2D.js.map} +0 -0
  45. /package/dist/{account-level-OX34JQ7C.js.map → account-level-7UOXIAB7.js.map} +0 -0
  46. /package/dist/{add-TKHBYZF6.js.map → add-ZMOFKHFR.js.map} +0 -0
  47. /package/dist/{ads-U33JFGCR.js.map → ads-B4HSLQMP.js.map} +0 -0
  48. /package/dist/{ads-ZR5D7BZT.js.map → ads-FQKWQBVZ.js.map} +0 -0
  49. /package/dist/{adsets-3NIYL2GQ.js.map → adsets-BG3KZ53Y.js.map} +0 -0
  50. /package/dist/{asset-writes-5ZKZDPQ4.js.map → asset-writes-55AP6IJM.js.map} +0 -0
  51. /package/dist/{audience-writes-NL6NRLLY.js.map → audience-writes-USX37PPI.js.map} +0 -0
  52. /package/dist/{audiences-DL267GNQ.js.map → audiences-G4GJZUIT.js.map} +0 -0
  53. /package/dist/{campaigns-RXDC5FSQ.js.map → campaigns-DNA7TN2T.js.map} +0 -0
  54. /package/dist/{catalogs-QAZ7ZZ5R.js.map → catalogs-7AG7YVMI.js.map} +0 -0
  55. /package/dist/{chunk-UE5ZFTDL.js.map → chunk-J43KP5NE.js.map} +0 -0
  56. /package/dist/{chunk-EGM42UKF.js.map → chunk-SXKBGTX2.js.map} +0 -0
  57. /package/dist/{copy-writes-QYN6PBU2.js.map → copy-writes-NJSSVTGB.js.map} +0 -0
  58. /package/dist/{creatives-CPLH3KHQ.js.map → creatives-4AD65R3V.js.map} +0 -0
  59. /package/dist/{custom-conversions-CTJVAZKC.js.map → custom-conversions-BDXRIYJW.js.map} +0 -0
  60. /package/dist/{flows-FRWZWHXZ.js.map → flows-PP6BRBD7.js.map} +0 -0
  61. /package/dist/{instant-experiences-EJWYFWDT.js.map → instant-experiences-JBN26DUT.js.map} +0 -0
  62. /package/dist/{leads-FEEWX7OO.js.map → leads-YWURF6YR.js.map} +0 -0
  63. /package/dist/{media-PUOLJUN3.js.map → media-BITGRDCO.js.map} +0 -0
  64. /package/dist/{meta-SPPSYRMC.js.map → meta-MY2CIGLA.js.map} +0 -0
  65. /package/dist/{page-photos-ZBMJLL5V.js.map → page-photos-ZP7APYIE.js.map} +0 -0
  66. /package/dist/{rule-writes-6XP7G35U.js.map → rule-writes-GE5URXYA.js.map} +0 -0
  67. /package/dist/{rules-BRULCGRV.js.map → rules-6O5ALFJD.js.map} +0 -0
  68. /package/dist/{studies-357M2C2K.js.map → studies-LZ4RWESW.js.map} +0 -0
  69. /package/dist/{study-writes-HXUQRPIK.js.map → study-writes-3WXJDSDU.js.map} +0 -0
  70. /package/dist/{targeting-7T7XHBIX.js.map → targeting-DEM7YHWM.js.map} +0 -0
  71. /package/dist/{write-commands-4KI6T2NF.js.map → write-commands-EQU4U746.js.map} +0 -0
@@ -1,11 +1,9 @@
1
1
  import {
2
- COLLAPSED_HINT,
3
2
  failApi,
4
3
  failValidation,
5
- listedTag,
6
4
  renderEffectiveEntry,
7
5
  tagsListHints
8
- } from "./chunk-TY4MTOTL.js";
6
+ } from "./chunk-MIIY3MVK.js";
9
7
  import {
10
8
  CHAT_READ_ARG
11
9
  } from "./chunk-X32MFGWW.js";
@@ -36,32 +34,26 @@ import "./chunk-YQSBHWOI.js";
36
34
 
37
35
  // src/commands/tags/index.ts
38
36
  import { defineCommand } from "citty";
39
- var LIST_OUTPUT_DESCRIPTION = "Output format: json|md. Default: json (the envelope); md prints one readable block per tag";
40
- var LIST_FULL_DESCRIPTION = "Print every config value whole, a custom `code` script included (by default a long value shows as its size)";
41
- var LIST_JSON_DESCRIPTION = "Same as the default: the JSON envelope (kept for older calls)";
42
37
  registerSchema({
43
38
  command: "tags.list",
44
- description: "Effective marketing tags for this chat: production tags overlaid with the changes staged in this chat, as the JSON envelope (`data` is one row per tag; `--output md` for a readable block per tag). Each tag's readable config is included (secrets are never included) \u2014 e.g. the Clarity projectId or GA4 measurementId \u2014 so reuse a stored value to pre-fill a follow-up change instead of asking the user for something we already have. A long value (a custom `code` script) shows as its size under `collapsed`; `--full` prints it whole. The printed refs (tag ids or tag_temp_*) are exactly what flow side-effect tagIds should reference. Read-only \u2014 every tag change (create, edit, delete) goes through the request_tag_input approval tool; `baker tags unstage` takes back one this chat staged.",
39
+ description: "Effective marketing tags for this chat: production tags overlaid with the changes staged in this chat. Prints each tag's readable config in full (secrets are never included) \u2014 e.g. the Clarity projectId, GA4 measurementId, or the entire custom `code` snippet \u2014 so reuse a stored value to pre-fill a follow-up change instead of asking the user for something we already have. The printed refs (tag ids or tag_temp_*) are exactly what flow side-effect tagIds should reference. Read-only \u2014 every tag change (create, edit, delete) goes through the request_tag_input approval tool; `baker tags unstage` takes back one this chat staged.",
45
40
  args: {
46
- output: { type: "string", description: LIST_OUTPUT_DESCRIPTION, required: false, default: "json" },
47
- full: { type: "boolean", description: LIST_FULL_DESCRIPTION, required: false },
48
- json: { type: "boolean", description: LIST_JSON_DESCRIPTION, required: false }
41
+ json: { type: "boolean", description: "Print the raw JSON envelope instead of the readable list", required: false }
49
42
  }
50
43
  });
51
- async function listTags(output, full) {
44
+ async function listTags(json) {
52
45
  try {
53
46
  const chatId = requireChatId();
54
47
  const response = await apiPost("/api/tags/list", { chatId });
55
- const tags = full ? response.tags : response.tags.map(listedTag);
56
- const hints = [...tagsListHints(), ...tags.some((tag) => tag.collapsed) ? [COLLAPSED_HINT] : []];
57
- if (output !== "md") {
58
- writeJson({ ok: true, ...rowsAsData({ tags }, "tags"), hints });
48
+ const hints = tagsListHints();
49
+ if (json) {
50
+ writeJson({ ok: true, ...rowsAsData(response, "tags"), hints });
59
51
  return;
60
52
  }
61
- if (tags.length === 0) {
53
+ if (response.tags.length === 0) {
62
54
  process.stdout.write("No tags configured.\n");
63
55
  } else {
64
- process.stdout.write(`${tags.map(renderEffectiveEntry).join("\n")}
56
+ process.stdout.write(`${response.tags.map(renderEffectiveEntry).join("\n")}
65
57
  `);
66
58
  }
67
59
  for (const hint of hints) {
@@ -73,18 +65,16 @@ async function listTags(output, full) {
73
65
  }
74
66
  }
75
67
  var listArgs = {
76
- output: { type: "string", description: LIST_OUTPUT_DESCRIPTION, default: "json" },
77
- full: { type: "boolean", description: LIST_FULL_DESCRIPTION },
78
- json: { type: "boolean", description: LIST_JSON_DESCRIPTION }
68
+ json: { type: "boolean", description: "Print the raw JSON envelope instead of the readable list" }
79
69
  };
80
70
  var listCommand = defineCommand({
81
71
  meta: {
82
72
  name: "list",
83
- description: "Effective tags for this chat (production + staged) as the JSON envelope, with each tag's readable config (secrets excluded) \u2014 reuse a stored value to pre-fill a change rather than asking the user. Refs printed here are what flow side-effect tagIds should use. A custom `code` script shows as its size; --full prints it. Start here: baker tags list | baker tags list --output md"
73
+ description: "Effective tags for this chat (production + staged), with each tag's full readable config (secrets excluded) \u2014 reuse a stored value to pre-fill a change rather than asking the user. Refs printed here are what flow side-effect tagIds should use. Example: baker tags list"
84
74
  },
85
75
  args: listArgs,
86
76
  run: async ({ args }) => {
87
- await listTags(args.output, args.full === true);
77
+ await listTags(args.json === true);
88
78
  }
89
79
  });
90
80
  async function listDraft(chat) {
@@ -164,13 +154,12 @@ Every tag change \u2014 create, edit, or delete \u2014 goes through the request_
164
154
 
165
155
  Refs: \`baker tags list\` prints each tag's ref \u2014 a real tag id, or tag_temp_* for creates staged in this chat. Use these refs as flow side-effect tagIds; they keep resolving after publish.
166
156
 
167
- \`baker tags list\` prints the JSON envelope (\`--output md\` to read it), with each tag's readable config (secrets excluded) \u2014 the Clarity projectId, GA4 measurementId, etc.; a custom \`code\` script shows as its size until \`--full\`. Reuse a stored value to pre-fill a follow-up change instead of asking the user for something already installed.
157
+ \`baker tags list\` prints each tag's readable config in full (secrets excluded) \u2014 the Clarity projectId, GA4 measurementId, the whole custom \`code\` snippet, etc. Reuse a stored value to pre-fill a follow-up change instead of asking the user for something already installed.
168
158
 
169
159
  To take back a change this chat staged (before Publish), \`baker tags unstage <ref>\` \u2014 the ref \`baker tags draft\` prints \u2014 or \`--all\`. It never touches a live tag.
170
160
 
171
161
  Examples:
172
- baker tags list # production + staged, config + secret status, as the JSON envelope
173
- baker tags list --output md --full # readable, custom code scripts whole
162
+ baker tags list # production + staged, full readable config + secret status
174
163
  baker tags draft # review the staged changes awaiting publish
175
164
  baker tags unstage tag_temp_abc123 # take back one staged change
176
165
  Full guide: __tooling__/docs/tools/baker/tags.md`
@@ -191,4 +180,4 @@ export {
191
180
  tagsCommand,
192
181
  unstageBody
193
182
  };
194
- //# sourceMappingURL=tags-DFCLKJX7.js.map
183
+ //# sourceMappingURL=tags-IQ6BCRLE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/tags/index.ts"],"sourcesContent":["import type { TagsDraftListResponse, TagsListResponse, TagsUnstageRequest, TagsUnstageResponse } from \"@baker/api\";\nimport { defineCommand } from \"citty\";\nimport { apiPost } from \"../../client.ts\";\nimport { requireChatId, resolveChatId } from \"../../env.ts\";\nimport { rowsAsData, writeJson } from \"../../output.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { CHAT_READ_ARG } from \"../chat-arg.ts\";\nimport { failApi, failValidation, renderEffectiveEntry, tagsListHints } from \"./shared.ts\";\n\nregisterSchema({\n command: \"tags.list\",\n description:\n \"Effective marketing tags for this chat: production tags overlaid with the changes staged in this chat. Prints each tag's readable config in full (secrets are never included) — e.g. the Clarity projectId, GA4 measurementId, or the entire custom `code` snippet — so reuse a stored value to pre-fill a follow-up change instead of asking the user for something we already have. The printed refs (tag ids or tag_temp_*) are exactly what flow side-effect tagIds should reference. Read-only — every tag change (create, edit, delete) goes through the request_tag_input approval tool; `baker tags unstage` takes back one this chat staged.\",\n args: {\n json: { type: \"boolean\", description: \"Print the raw JSON envelope instead of the readable list\", required: false },\n },\n});\n\nasync function listTags(json: boolean): Promise<void> {\n try {\n const chatId = requireChatId();\n const response = await apiPost<TagsListResponse>(\"/api/tags/list\", { chatId });\n const hints = tagsListHints();\n if (json) {\n writeJson({ ok: true, ...rowsAsData(response, \"tags\"), hints });\n return;\n }\n if (response.tags.length === 0) {\n process.stdout.write(\"No tags configured.\\n\");\n } else {\n process.stdout.write(`${response.tags.map(renderEffectiveEntry).join(\"\\n\")}\\n`);\n }\n // stdout stays the list and nothing else, so a reader piping it keeps\n // parsing it; the hints go to stderr, where the agent still reads them.\n for (const hint of hints) {\n process.stderr.write(`${hint}\\n`);\n }\n } catch (err) {\n failApi(err);\n }\n}\n\nconst listArgs = {\n json: { type: \"boolean\", description: \"Print the raw JSON envelope instead of the readable list\" },\n} as const;\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description:\n \"Effective tags for this chat (production + staged), with each tag's full readable config (secrets excluded) — reuse a stored value to pre-fill a change rather than asking the user. Refs printed here are what flow side-effect tagIds should use. Example: baker tags list\",\n },\n args: listArgs,\n run: async ({ args }) => {\n await listTags(args.json === true);\n },\n});\n\nasync function listDraft(chat?: unknown): Promise<void> {\n try {\n const chatId = resolveChatId(chat);\n const response = await apiPost<TagsDraftListResponse>(\"/api/tags/draft\", { chatId });\n writeJson({ ok: true, data: response, hints: tagsListHints() });\n } catch (err) {\n failApi(err);\n }\n}\n\nconst draftCommand = defineCommand({\n meta: {\n name: \"draft\",\n description:\n \"Review the tag changes staged in this chat (read-only). Staged changes were approved via request_tag_input and apply when the chat is published. To drop one, `baker tags unstage <ref>` with the ref printed here (or --all); to amend one, propose a follow-up change through the same tool. Takes --chat <id> to read an earlier chat's staged changes instead.\",\n },\n args: { chat: CHAT_READ_ARG },\n run: async ({ args }) => {\n await listDraft(args.chat);\n },\n});\n\nregisterSchema({\n command: \"tags.unstage\",\n description:\n \"Take back a tag change this chat staged, before Publish — the same as discarding its row in the change review. Pass the ref `baker tags draft` prints (a tag id, or tag_temp_* for a staged create), or --all for every staged tag change. Taking back a staged create also drops the secrets the user entered for it. Never touches a live tag: to change or remove one, propose the change through request_tag_input.\",\n args: {\n ref: { type: \"string\", description: \"The staged change's ref, from `baker tags draft`\", required: false },\n all: { type: \"boolean\", description: \"Take back every tag change staged in this chat\", required: false },\n },\n});\n\n/** The request for one unstage, checked before the round trip. */\nexport function unstageBody(args: { ref?: string; all?: boolean }, chatId: string): TagsUnstageRequest {\n const ref = args.ref?.trim();\n if (args.all === true && ref) {\n failValidation(\"Pass one ref to take back that change, or --all for every staged tag change — not both.\");\n }\n if (args.all === true) {\n return { chatId, all: true };\n }\n if (!ref) {\n failValidation(\"Pass the ref of the staged change (from `baker tags draft`), or --all.\");\n }\n return { chatId, ref };\n}\n\nconst unstageCommand = defineCommand({\n meta: {\n name: \"unstage\",\n description:\n \"Take back a tag change this chat staged, before Publish. Examples: baker tags unstage tag_temp_abc123 | baker tags unstage --all\",\n },\n args: {\n ref: { type: \"positional\", description: \"The staged change's ref, from `baker tags draft`\", required: false },\n all: { type: \"boolean\", description: \"Take back every tag change staged in this chat\", required: false },\n },\n run: async ({ args }) => {\n try {\n const body = unstageBody(\n {\n ...(typeof args.ref === \"string\" ? { ref: args.ref } : {}),\n ...(args.all === true ? { all: true } : {}),\n },\n requireChatId(),\n );\n const response = await apiPost<TagsUnstageResponse>(\"/api/tags/draft-op/remove\", body);\n writeJson({\n ...response,\n hints: [\"Taken back: it does not apply when the chat is published. Live tags are unchanged.\"],\n });\n } catch (err) {\n failApi(err);\n }\n },\n});\n\nexport const tagsCommand = defineCommand({\n meta: {\n name: \"tags\",\n description: `Read the client's marketing/analytics tags (Meta pixel, GA4, Google Ads, GTM, Clarity, Hotjar, …) — production tags plus the changes staged in this chat.\n\nEvery tag change — create, edit, or delete — goes through the request_tag_input tool (baker_ui MCP server): propose one or more changes (each becomes a tab in one approval form), pre-fill the non-secret fields you know, and the user reviews, fills secrets, and approves or skips each. Secret values (accessToken, apiSecret, authorizationToken, apiKey, conversionToken, OAuth connections) never pass through the CLI or the chat.\n\nRefs: \\`baker tags list\\` prints each tag's ref — a real tag id, or tag_temp_* for creates staged in this chat. Use these refs as flow side-effect tagIds; they keep resolving after publish.\n\n\\`baker tags list\\` prints each tag's readable config in full (secrets excluded) — the Clarity projectId, GA4 measurementId, the whole custom \\`code\\` snippet, etc. Reuse a stored value to pre-fill a follow-up change instead of asking the user for something already installed.\n\nTo take back a change this chat staged (before Publish), \\`baker tags unstage <ref>\\` — the ref \\`baker tags draft\\` prints — or \\`--all\\`. It never touches a live tag.\n\nExamples:\n baker tags list # production + staged, full readable config + secret status\n baker tags draft # review the staged changes awaiting publish\n baker tags unstage tag_temp_abc123 # take back one staged change\nFull guide: __tooling__/docs/tools/baker/tags.md`,\n },\n subCommands: {\n list: listCommand,\n draft: draftCommand,\n unstage: unstageCommand,\n },\n // Bare `baker tags` lists the effective tags. `args` stays so citty knows this\n // command's flags when it scans rawArgs for a subcommand name, and `default` (not\n // `run`) dispatches the bare invocation — citty falls through to `run` after a\n // subcommand, so a `run` here would also list on every `baker tags draft`.\n args: listArgs,\n default: \"list\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,qBAAqB;AAQ9B,eAAe;AAAA,EACb,SAAS;AAAA,EACT,aACE;AAAA,EACF,MAAM;AAAA,IACJ,MAAM,EAAE,MAAM,WAAW,aAAa,4DAA4D,UAAU,MAAM;AAAA,EACpH;AACF,CAAC;AAED,eAAe,SAAS,MAA8B;AACpD,MAAI;AACF,UAAM,SAAS,cAAc;AAC7B,UAAM,WAAW,MAAM,QAA0B,kBAAkB,EAAE,OAAO,CAAC;AAC7E,UAAM,QAAQ,cAAc;AAC5B,QAAI,MAAM;AACR,gBAAU,EAAE,IAAI,MAAM,GAAG,WAAW,UAAU,MAAM,GAAG,MAAM,CAAC;AAC9D;AAAA,IACF;AACA,QAAI,SAAS,KAAK,WAAW,GAAG;AAC9B,cAAQ,OAAO,MAAM,uBAAuB;AAAA,IAC9C,OAAO;AACL,cAAQ,OAAO,MAAM,GAAG,SAAS,KAAK,IAAI,oBAAoB,EAAE,KAAK,IAAI,CAAC;AAAA,CAAI;AAAA,IAChF;AAGA,eAAW,QAAQ,OAAO;AACxB,cAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,CAAI;AAAA,IAClC;AAAA,EACF,SAAS,KAAK;AACZ,YAAQ,GAAG;AAAA,EACb;AACF;AAEA,IAAM,WAAW;AAAA,EACf,MAAM,EAAE,MAAM,WAAW,aAAa,2DAA2D;AACnG;AAEA,IAAM,cAAc,cAAc;AAAA,EAChC,MAAM;AAAA,IACJ,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;AAAA,EACA,MAAM;AAAA,IACJ,KAAK,EAAE,MAAM,cAAc,aAAa,oDAAoD,UAAU,MAAM;AAAA,IAC5G,KAAK,EAAE,MAAM,WAAW,aAAa,kDAAkD,UAAU,MAAM;AAAA,EACzG;AAAA,EACA,KAAK,OAAO,EAAE,KAAK,MAAM;AACvB,QAAI;AACF,YAAM,OAAO;AAAA,QACX;AAAA,UACE,GAAI,OAAO,KAAK,QAAQ,WAAW,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC;AAAA,UACxD,GAAI,KAAK,QAAQ,OAAO,EAAE,KAAK,KAAK,IAAI,CAAC;AAAA,QAC3C;AAAA,QACA,cAAc;AAAA,MAChB;AACA,YAAM,WAAW,MAAM,QAA6B,6BAA6B,IAAI;AACrF,gBAAU;AAAA,QACR,GAAG;AAAA,QACH,OAAO,CAAC,oFAAoF;AAAA,MAC9F,CAAC;AAAA,IACH,SAAS,KAAK;AACZ,cAAQ,GAAG;AAAA,IACb;AAAA,EACF;AACF,CAAC;AAEM,IAAM,cAAc,cAAc;AAAA,EACvC,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAef;AAAA,EACA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM;AAAA,EACN,SAAS;AACX,CAAC;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-PRPSV4VB.js";
5
5
  import {
6
6
  loadJsonFileArg
7
- } from "./chunk-OMJ7DVFJ.js";
7
+ } from "./chunk-ATVUGOXL.js";
8
8
  import {
9
9
  metaTargetingSchema
10
10
  } from "./chunk-3R62EYYX.js";
@@ -774,4 +774,4 @@ Start here before writing interests, behaviors, places or languages into an ad s
774
774
  export {
775
775
  targetingCommand
776
776
  };
777
- //# sourceMappingURL=targeting-7T7XHBIX.js.map
777
+ //# sourceMappingURL=targeting-DEM7YHWM.js.map
@@ -7,7 +7,7 @@ import {
7
7
  budgetBoostsFromFlags,
8
8
  clearArg,
9
9
  clearFromFlags
10
- } from "./chunk-EGM42UKF.js";
10
+ } from "./chunk-SXKBGTX2.js";
11
11
  import {
12
12
  bareAccountId,
13
13
  failWriteValidation,
@@ -25,7 +25,7 @@ import {
25
25
  stageOp,
26
26
  stageStatusChange,
27
27
  upper
28
- } from "./chunk-OMJ7DVFJ.js";
28
+ } from "./chunk-ATVUGOXL.js";
29
29
  import {
30
30
  buildCustomConversionRule
31
31
  } from "./chunk-3R62EYYX.js";
@@ -481,7 +481,7 @@ Example: baker ads meta adsets create --campaign 6123 --name "Reach ES" --optimi
481
481
  const file = loadJsonFileArg(args.file);
482
482
  const payload = mergePayload(file, adSetPayloadFromFlags(args, rawArgs, file));
483
483
  if (args["saved-audience"]) {
484
- const { savedAudienceTargeting, targetingFromSavedAudience } = await import("./audience-writes-NL6NRLLY.js");
484
+ const { savedAudienceTargeting, targetingFromSavedAudience } = await import("./audience-writes-USX37PPI.js");
485
485
  const saved = await savedAudienceTargeting(accountId, String(args["saved-audience"]));
486
486
  const merged = targetingFromSavedAudience(saved, payload.targeting);
487
487
  if ("refusal" in merged) failWriteValidation(merged.refusal);
@@ -1258,4 +1258,4 @@ export {
1258
1258
  retagSetPairs,
1259
1259
  targetingFromFlags
1260
1260
  };
1261
- //# sourceMappingURL=write-commands-4KI6T2NF.js.map
1261
+ //# sourceMappingURL=write-commands-EQU4U746.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koda-sl/baker-cli",
3
- "version": "0.868.0-dev.5be0a9a76",
3
+ "version": "0.868.0-dev.ebaaca9d0",
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/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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C,EAAE;AAC7G;AAEO,IAAM,iBACX;AAEK,SAAS,qBAAqB,OAA0B;AAC7D,QAAM,QAAQ,CAAC,MAAM,KAAK,MAAM,IAAI;AACpC,MAAI,MAAM,eAAe,QAAW;AAClC,UAAM,KAAK,MAAM,UAAU;AAAA,EAC7B;AACA,MAAI,MAAM,WAAW,QAAW;AAC9B,UAAM,KAAK,YAAY,MAAM,MAAM,GAAG;AAAA,EACxC;AACA,QAAM,aAAa;AAAA,IACjB,GAAG,MAAM,WAAW,IAAI,CAAC,UAAU,GAAG,KAAK,aAAQ;AAAA,IACnD,GAAG,MAAM,eAAe,IAAI,CAAC,UAAU,GAAG,KAAK,iBAAY;AAAA,EAC7D;AACA,MAAI,WAAW,SAAS,GAAG;AACzB,UAAM,KAAK,aAAa,WAAW,KAAK,IAAI,CAAC,GAAG;AAAA,EAClD;AACA,QAAM,SAAS,MAAM,KAAK,IAAI;AAK9B,QAAM,mBAAmB,sBAAsB,MAAM,IAAI;AACzD,QAAM,cAAc,OAAO,QAAQ,MAAM,MAAM,EAC5C,OAAO,CAAC,CAAC,GAAG,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":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/ads/meta/draft.ts","../src/commands/ads/meta/draft-status.ts"],"sourcesContent":["import type {\n MetaDraftClearResponse,\n MetaDraftListResponse,\n MetaDraftRemoveResponse,\n MetaDraftShowResponse,\n} from \"@baker/api/ads-meta\";\nimport { defineCommand } from \"citty\";\nimport { apiPost } from \"../../../client.ts\";\nimport { requireChatId, resolveChatId } from \"../../../env.ts\";\nimport { registerSchema, withEffect } from \"../../../schemas.ts\";\nimport { CHAT_READ_ARG, DRAFT_FULL_ARG } from \"../../chat-arg.ts\";\nimport { draftRefs, removeDraftRefs } from \"../../draft-refs.ts\";\nimport { draftListWhere, LIST_WHERE_ARG, requireDraftWhere, wholeDraftHints } from \"../../draft-where.ts\";\nimport { SHOW_FULL_ARG, showEnvelope } from \"../draft-show.ts\";\nimport { hintLines, withHints } from \"../hints.ts\";\nimport { writeJsonEnvelope } from \"../output.ts\";\nimport { renderDraftStatus } from \"./draft-status.ts\";\nimport { handleMetaError } from \"./shared.ts\";\n\nregisterSchema({\n command: \"ads.meta.draft\",\n routes: [\"POST /api/ads/meta/draft\"],\n effect: \"read\",\n description:\n \"Review every Meta op staged on this chat, one line each: ref · kind · summary · the ad set (or campaign) a staged ad (or ad set) goes into with the status it publishes under · what it waits on · ✗ blocked: <why> when publish would now refuse it, and after a publish ✓ applied → id or ✗ failed: <error>. `draft show <ref>` prints one op's payload (--full for lists over 50 items).\",\n args: {\n json: { type: \"boolean\", description: \"Raw JSON envelope instead of the readable list\", required: false },\n full: { type: \"boolean\", description: DRAFT_FULL_ARG.description, required: false },\n chat: { type: \"string\", description: \"Read another chat's draft instead of this one\", required: false },\n where: LIST_WHERE_ARG,\n },\n});\n\n/**\n * The readable one-line-per-op view is the default, like the Google, LinkedIn and X drafts;\n * `--json` (or `--output json`) returns the raw envelope for tools.\n */\nasync function listDraft(json: boolean, chat?: unknown, full = false, selector?: string): Promise<void> {\n const where = selector === undefined ? undefined : requireDraftWhere(selector);\n try {\n const chatId = resolveChatId(chat);\n const response = await apiPost<{ ok: boolean; data?: MetaDraftListResponse }>(\"/api/ads/meta/draft\", {\n chatId,\n ...(full || where ? { full: true } : {}),\n });\n if (where && selector !== undefined && response.ok && response.data) {\n const narrowed = draftListWhere(response.data, where, selector);\n writeJsonEnvelope(withHints({ ...response, data: narrowed.data }, narrowed.hints));\n return;\n }\n if (json || full || !response.ok || !response.data) {\n const whole = response.ok && response.data ? wholeDraftHints(response.data.ops, \"baker ads meta draft list\") : [];\n writeJsonEnvelope(withHints(response, whole));\n return;\n }\n process.stdout.write(`${renderDraftStatus(response.data)}${hintLines(response)}\\n`);\n } catch (err) {\n handleMetaError(err);\n }\n}\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description:\n \"Show every Meta write op staged in this chat, one line each (ref · kind · summary · parent ad set or campaign and its status · dependencies · post-publish result), with staged ads counted by their ad set's status; --json for the raw envelope, --full for every op's payload too. Publishing reaches the real ad account, so review this before you finish. Example: baker ads meta draft\",\n },\n args: {\n json: { type: \"boolean\", description: \"Print the raw JSON envelope instead of the readable list\" },\n full: DRAFT_FULL_ARG,\n chat: CHAT_READ_ARG,\n where: LIST_WHERE_ARG,\n },\n run: async ({ args }) => {\n await listDraft(\n args.json === true,\n args.chat,\n args.full === true,\n typeof args.where === \"string\" ? args.where : undefined,\n );\n },\n});\n\nconst showCommand = defineCommand({\n meta: {\n name: \"show\",\n description:\n \"Print the staged payload for one op — the receipt to verify a change looks right before publish. A list longer than 50 items (a customer list's members) prints as its count; --full prints every item. Example: baker ads meta draft show meta_temp_abc123\",\n },\n args: {\n ref: { type: \"positional\", description: \"Op ref (meta_temp_* for creates, target id for updates)\", required: true },\n // `show` always prints the envelope; `--json` is the spelling `list` taught, so it is accepted here too.\n json: { type: \"boolean\", description: \"Accepted for symmetry with list; show always prints the JSON envelope\" },\n chat: CHAT_READ_ARG,\n full: SHOW_FULL_ARG,\n },\n run: async ({ args }) => {\n try {\n const chatId = resolveChatId(args.chat);\n const response = await apiPost<{ ok: true; data: MetaDraftShowResponse }>(\"/api/ads/meta/draft/show\", {\n chatId,\n ref: args.ref,\n });\n writeJsonEnvelope(showEnvelope(response, args.full === true));\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nconst removeCommand = defineCommand({\n meta: {\n name: \"remove\",\n description:\n \"Drop staged Meta ops — one, or many in one call. Removing a create cascades to everything that depends on it. Example: baker ads meta draft remove meta_temp_abc123 meta_temp_def456\",\n },\n args: {\n ref: {\n type: \"positional\",\n description: \"Op ref(s) (meta_temp_* for creates, target id for updates) — several, space- or comma-separated\",\n required: true,\n },\n },\n run: async ({ args }) => {\n const refs = draftRefs(args._);\n if (refs.length > 1) {\n await removeDraftRefs(\"/api/ads/meta/draft/remove\", refs);\n return;\n }\n try {\n const chatId = requireChatId();\n const response = await apiPost<{ ok: true; data: MetaDraftRemoveResponse }>(\"/api/ads/meta/draft/remove\", {\n chatId,\n ref: args.ref,\n });\n writeJsonEnvelope(response);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nconst clearCommand = defineCommand({\n meta: {\n name: \"clear\",\n description:\n \"Discard ALL staged Meta ops in this chat's draft — nothing will apply on publish. Example: baker ads meta draft clear\",\n },\n run: async () => {\n try {\n const chatId = requireChatId();\n const response = await apiPost<{ ok: true; data: MetaDraftClearResponse }>(\"/api/ads/meta/draft/clear\", {\n chatId,\n });\n writeJsonEnvelope(response);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nwithEffect({ effect: \"read\", routes: [\"POST /api/ads/meta/draft\"] }, listCommand);\nwithEffect({ effect: \"read\", routes: [\"POST /api/ads/meta/draft/show\"] }, showCommand);\nwithEffect({ effect: \"unstage\", routes: [\"POST /api/ads/meta/draft/remove\"] }, removeCommand);\nwithEffect({ effect: \"unstage\", routes: [\"POST /api/ads/meta/draft/clear\"] }, clearCommand);\n\nexport const metaDraftCommand = defineCommand({\n meta: {\n name: \"draft\",\n description:\n \"Review and edit the Meta write ops staged in this chat BEFORE publish. Subcommands: list (default), show, remove, clear. Ops never hit Meta until the chat is published. `list` and `show` take --chat <id> to read an earlier chat's changes instead.\",\n },\n // Declared on the parent too: `default: \"list\"` dispatches the bare `draft --chat <id>` form, and\n // citty prints help for a flag the parent does not know instead of forwarding it.\n args: {\n json: { type: \"boolean\", description: \"Print the raw JSON envelope instead of the readable list\" },\n full: DRAFT_FULL_ARG,\n chat: CHAT_READ_ARG,\n where: LIST_WHERE_ARG,\n },\n subCommands: { list: listCommand, show: showCommand, remove: removeCommand, clear: clearCommand },\n // `default` (not `run`) dispatches the bare invocation: citty falls through to `run`\n // after dispatching a subcommand, so a `run` here would list the draft a second time\n // on every `draft list` / `draft remove` / `draft clear`.\n default: \"list\",\n});\n","import type { MetaDraftListResponse, MetaDraftOpView } from \"@baker/api/ads-meta\";\n\n/**\n * Render the staged Meta draft as one line per op — ref, kind, summary, what it\n * waits on and, after a publish, what happened to it. The Google, LinkedIn and\n * X drafts already print a readable view by default; Meta printed the pretty\n * JSON envelope, and agents piped every read through python to get these same\n * columns back. Pure: takes the draft-list response, returns text.\n */\n\nconst STATUS_HEADINGS: Record<MetaDraftListResponse[\"status\"], string> = {\n active: \"staged\",\n publishing: \"publishing\",\n applied: \"published\",\n partial: \"published with failures\",\n discarded: \"discarded\",\n none: \"none\",\n};\n\nfunction plural(count: number, word: string): string {\n return `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n}\n\nfunction headingLine(draft: MetaDraftListResponse): string {\n const heading = STATUS_HEADINGS[draft.status];\n if (draft.status === \"active\" || draft.status === \"discarded\") {\n return `Meta Ads — ${plural(draft.count, \"change\")} ${heading} · ${draft.mode}`;\n }\n const counts = new Map<string, number>();\n for (const op of draft.ops) {\n const status = op.result?.status ?? \"pending\";\n counts.set(status, (counts.get(status) ?? 0) + 1);\n }\n const summary = [...counts].map(([status, count]) => `${count} ${status}`).join(\", \");\n return `Meta Ads — ${heading} · ${summary} · ${draft.mode}`;\n}\n\n/** A failed op: why, and what of it already reached Meta. */\nfunction failedPart(result: NonNullable<MetaDraftOpView[\"result\"]>): string {\n const landed = result.landed ? ` (${result.landed})` : \"\";\n return `✗ failed: ${result.error ?? \"no reason recorded\"}${landed}`;\n}\n\nfunction resultPart(op: MetaDraftOpView): string | undefined {\n const result = op.result;\n if (!result) {\n return undefined;\n }\n if (result.status === \"failed\") {\n return failedPart(result);\n }\n if (result.status === \"skipped\") {\n // Publish records either the dependency ref that did not apply or a plain reason; either way the op is finished.\n const because = result.skippedBecause;\n if (because && op.dependsOn.includes(because)) {\n return `✗ skipped: ${because} did not apply`;\n }\n return `✗ skipped: ${because ?? \"a change it needs did not apply\"}`;\n }\n const id = result.id ?? result.hash;\n const applied = `✓ ${result.status}${id ? ` → ${id}` : \"\"}`;\n const verification = result.verification;\n if (verification && verification.status !== \"confirmed\") {\n return `${applied} (read-back ${verification.status}${verification.note ? `: ${verification.note}` : \"\"})`;\n }\n return applied;\n}\n\nconst PARENT_WORD: Record<string, string> = {\n \"ad.create\": \"ad set\",\n \"ad.copy\": \"ad set\",\n \"adSet.create\": \"campaign\",\n \"adSet.copy\": \"campaign\",\n};\n\nconst STAGED_AD_KINDS: ReadonlySet<string> = new Set([\"ad.create\", \"ad.copy\"]);\n\n/** Where a staged ad (or ad set) goes, and the status that parent publishes with. */\nfunction parentPart(op: MetaDraftOpView): string | undefined {\n const parent = op.parent;\n if (!parent) {\n return undefined;\n }\n const word = PARENT_WORD[op.kind] ?? \"parent\";\n const named = parent.name ? `\"${parent.name}\" (${parent.ref})` : parent.ref;\n const staged = parent.staged ? \", staged here\" : \"\";\n const status = parent.status\n ? `${parent.statusBefore ? `${parent.statusBefore} → ` : \"\"}${parent.status}`\n : \"status not recorded\";\n return `in ${word} ${named}${staged} ${status}`;\n}\n\n/** \"Which staged ads will run\" in one line: ads counted by the status of the ad set they go into. */\nfunction adParentStatusLine(ops: readonly MetaDraftOpView[]): string | undefined {\n const counts = new Map<string, number>();\n for (const op of ops) {\n if (STAGED_AD_KINDS.has(op.kind) && op.parent) {\n const status = op.parent.status ?? \"not recorded\";\n counts.set(status, (counts.get(status) ?? 0) + 1);\n }\n }\n if (counts.size === 0) {\n return undefined;\n }\n return `Staged ads by ad set status: ${[...counts].map(([status, count]) => `${count} ${status}`).join(\", \")}`;\n}\n\nfunction readinessLine(ops: readonly MetaDraftOpView[]): string {\n const blocked = ops.filter((op) => op.blocked);\n if (blocked.length === 0) {\n return \"Every change passed its checks when staged — no need to re-check them.\";\n }\n // A first publish holds every change beside a refused one; only the refused ones need fixing.\n const heldBack = blocked.filter((op) => op.heldBack).length;\n const refused = blocked.length - heldBack;\n const held =\n heldBack === 0\n ? \"\"\n : `; the other ${plural(heldBack, \"change\")} ${heldBack === 1 ? \"is\" : \"are\"} held back with ${refused === 1 ? \"it\" : \"them\"} and need${heldBack === 1 ? \"s\" : \"\"} nothing`;\n return `${plural(refused, \"change\")} passed its checks when staged but would be refused now (✗ blocked below) — fix or remove ${refused === 1 ? \"it\" : \"them\"} before publishing${held}.`;\n}\n\nfunction opLine(op: MetaDraftOpView, showAccount: boolean): string {\n const parts = [op.ref, op.kind, op.summary];\n if (op.target && op.target !== op.ref) {\n parts.push(`target ${op.target}`);\n }\n if (showAccount) {\n parts.push(`account ${op.accountId}`);\n }\n const parent = parentPart(op);\n if (parent) {\n parts.push(parent);\n }\n if (op.dependsOn.length > 0) {\n parts.push(`after ${op.dependsOn.join(\", \")}`);\n }\n if (op.blocked) {\n parts.push(`✗ blocked: ${op.blocked}`);\n }\n const result = resultPart(op);\n if (result) {\n parts.push(result);\n }\n // Creative copy and provider errors can carry line breaks; one op stays one line.\n return ` ${parts.join(\" · \").replace(/[\\r\\n]+/g, \" \")}`;\n}\n\nexport function renderDraftStatus(draft: MetaDraftListResponse): string {\n if (draft.status === \"none\" || draft.count === 0) {\n return \"No staged Meta changes on this chat.\";\n }\n const lines = [headingLine(draft)];\n if (draft.status === \"active\") {\n lines.push(\"Publishing makes every change real on the ad account.\", readinessLine(draft.ops));\n }\n const adParents = adParentStatusLine(draft.ops);\n if (adParents) {\n lines.push(adParents);\n }\n lines.push(\"\");\n // A draft may span several ad accounts; the account is only noise when there is one.\n const showAccount = new Set(draft.ops.map((op) => op.accountId)).size > 1;\n for (const op of draft.ops) {\n lines.push(opLine(op, showAccount));\n }\n if (draft.advisories.length > 0) {\n lines.push(\"\", \"Advisories\");\n for (const advisory of draft.advisories) {\n lines.push(` ! ${advisory.ref}: ${advisory.message}`);\n }\n }\n lines.push(\n \"\",\n \"Staged payload for one op: baker ads meta draft show <ref> (--full for lists over 50 items) · raw envelope: --json\",\n );\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,qBAAqB;;;ACI9B,IAAM,kBAAmE;AAAA,EACvE,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,MAAM;AACR;AAEA,SAAS,OAAO,OAAe,MAAsB;AACnD,SAAO,GAAG,KAAK,IAAI,IAAI,GAAG,UAAU,IAAI,KAAK,GAAG;AAClD;AAEA,SAAS,YAAY,OAAsC;AACzD,QAAM,UAAU,gBAAgB,MAAM,MAAM;AAC5C,MAAI,MAAM,WAAW,YAAY,MAAM,WAAW,aAAa;AAC7D,WAAO,mBAAc,OAAO,MAAM,OAAO,QAAQ,CAAC,IAAI,OAAO,SAAM,MAAM,IAAI;AAAA,EAC/E;AACA,QAAM,SAAS,oBAAI,IAAoB;AACvC,aAAW,MAAM,MAAM,KAAK;AAC1B,UAAM,SAAS,GAAG,QAAQ,UAAU;AACpC,WAAO,IAAI,SAAS,OAAO,IAAI,MAAM,KAAK,KAAK,CAAC;AAAA,EAClD;AACA,QAAM,UAAU,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC,QAAQ,KAAK,MAAM,GAAG,KAAK,IAAI,MAAM,EAAE,EAAE,KAAK,IAAI;AACpF,SAAO,mBAAc,OAAO,SAAM,OAAO,SAAM,MAAM,IAAI;AAC3D;AAGA,SAAS,WAAW,QAAwD;AAC1E,QAAM,SAAS,OAAO,SAAS,KAAK,OAAO,MAAM,M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AAAA;AAAA;AAAA,EAIhG,SAAS;AACX,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/tags/index.ts"],"sourcesContent":["import type { TagsDraftListResponse, TagsListResponse, TagsUnstageRequest, TagsUnstageResponse } from \"@baker/api\";\nimport { defineCommand } from \"citty\";\nimport { apiPost } from \"../../client.ts\";\nimport { requireChatId, resolveChatId } from \"../../env.ts\";\nimport { rowsAsData, writeJson } from \"../../output.ts\";\nimport { registerSchema } from \"../../schemas.ts\";\nimport { CHAT_READ_ARG } from \"../chat-arg.ts\";\nimport {\n COLLAPSED_HINT,\n failApi,\n failValidation,\n type ListedTag,\n listedTag,\n renderEffectiveEntry,\n tagsListHints,\n} from \"./shared.ts\";\n\nconst LIST_OUTPUT_DESCRIPTION =\n \"Output format: json|md. Default: json (the envelope); md prints one readable block per tag\";\nconst LIST_FULL_DESCRIPTION =\n \"Print every config value whole, a custom `code` script included (by default a long value shows as its size)\";\nconst LIST_JSON_DESCRIPTION = \"Same as the default: the JSON envelope (kept for older calls)\";\n\nregisterSchema({\n command: \"tags.list\",\n description:\n \"Effective marketing tags for this chat: production tags overlaid with the changes staged in this chat, as the JSON envelope (`data` is one row per tag; `--output md` for a readable block per tag). Each tag's readable config is included (secrets are never included) — e.g. the Clarity projectId or GA4 measurementId — so reuse a stored value to pre-fill a follow-up change instead of asking the user for something we already have. A long value (a custom `code` script) shows as its size under `collapsed`; `--full` prints it whole. The printed refs (tag ids or tag_temp_*) are exactly what flow side-effect tagIds should reference. Read-only — every tag change (create, edit, delete) goes through the request_tag_input approval tool; `baker tags unstage` takes back one this chat staged.\",\n args: {\n output: { type: \"string\", description: LIST_OUTPUT_DESCRIPTION, required: false, default: \"json\" },\n full: { type: \"boolean\", description: LIST_FULL_DESCRIPTION, required: false },\n json: { type: \"boolean\", description: LIST_JSON_DESCRIPTION, required: false },\n },\n});\n\nasync function listTags(output: unknown, full: boolean): Promise<void> {\n try {\n const chatId = requireChatId();\n const response = await apiPost<TagsListResponse>(\"/api/tags/list\", { chatId });\n const tags: ListedTag[] = full ? response.tags : response.tags.map(listedTag);\n const hints = [...tagsListHints(), ...(tags.some((tag) => tag.collapsed) ? [COLLAPSED_HINT] : [])];\n if (output !== \"md\") {\n writeJson({ ok: true, ...rowsAsData({ tags }, \"tags\"), hints });\n return;\n }\n if (tags.length === 0) {\n process.stdout.write(\"No tags configured.\\n\");\n } else {\n process.stdout.write(`${tags.map(renderEffectiveEntry).join(\"\\n\")}\\n`);\n }\n // stdout stays the list and nothing else, so a reader piping it keeps\n // parsing it; the hints go to stderr, where the agent still reads them.\n for (const hint of hints) {\n process.stderr.write(`${hint}\\n`);\n }\n } catch (err) {\n failApi(err);\n }\n}\n\nconst listArgs = {\n output: { type: \"string\", description: LIST_OUTPUT_DESCRIPTION, default: \"json\" },\n full: { type: \"boolean\", description: LIST_FULL_DESCRIPTION },\n json: { type: \"boolean\", description: LIST_JSON_DESCRIPTION },\n} as const;\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description:\n \"Effective tags for this chat (production + staged) as the JSON envelope, with each tag's readable config (secrets excluded) — reuse a stored value to pre-fill a change rather than asking the user. Refs printed here are what flow side-effect tagIds should use. A custom `code` script shows as its size; --full prints it. Start here: baker tags list | baker tags list --output md\",\n },\n args: listArgs,\n run: async ({ args }) => {\n await listTags(args.output, args.full === true);\n },\n});\n\nasync function listDraft(chat?: unknown): Promise<void> {\n try {\n const chatId = resolveChatId(chat);\n const response = await apiPost<TagsDraftListResponse>(\"/api/tags/draft\", { chatId });\n writeJson({ ok: true, data: response, hints: tagsListHints() });\n } catch (err) {\n failApi(err);\n }\n}\n\nconst draftCommand = defineCommand({\n meta: {\n name: \"draft\",\n description:\n \"Review the tag changes staged in this chat (read-only). Staged changes were approved via request_tag_input and apply when the chat is published. To drop one, `baker tags unstage <ref>` with the ref printed here (or --all); to amend one, propose a follow-up change through the same tool. Takes --chat <id> to read an earlier chat's staged changes instead.\",\n },\n args: { chat: CHAT_READ_ARG },\n run: async ({ args }) => {\n await listDraft(args.chat);\n },\n});\n\nregisterSchema({\n command: \"tags.unstage\",\n description:\n \"Take back a tag change this chat staged, before Publish — the same as discarding its row in the change review. Pass the ref `baker tags draft` prints (a tag id, or tag_temp_* for a staged create), or --all for every staged tag change. Taking back a staged create also drops the secrets the user entered for it. Never touches a live tag: to change or remove one, propose the change through request_tag_input.\",\n args: {\n ref: { type: \"string\", description: \"The staged change's ref, from `baker tags draft`\", required: false },\n all: { type: \"boolean\", description: \"Take back every tag change staged in this chat\", required: false },\n },\n});\n\n/** The request for one unstage, checked before the round trip. */\nexport function unstageBody(args: { ref?: string; all?: boolean }, chatId: string): TagsUnstageRequest {\n const ref = args.ref?.trim();\n if (args.all === true && ref) {\n failValidation(\"Pass one ref to take back that change, or --all for every staged tag change — not both.\");\n }\n if (args.all === true) {\n return { chatId, all: true };\n }\n if (!ref) {\n failValidation(\"Pass the ref of the staged change (from `baker tags draft`), or --all.\");\n }\n return { chatId, ref };\n}\n\nconst unstageCommand = defineCommand({\n meta: {\n name: \"unstage\",\n description:\n \"Take back a tag change this chat staged, before Publish. Examples: baker tags unstage tag_temp_abc123 | baker tags unstage --all\",\n },\n args: {\n ref: { type: \"positional\", description: \"The staged change's ref, from `baker tags draft`\", required: false },\n all: { type: \"boolean\", description: \"Take back every tag change staged in this chat\", required: false },\n },\n run: async ({ args }) => {\n try {\n const body = unstageBody(\n {\n ...(typeof args.ref === \"string\" ? { ref: args.ref } : {}),\n ...(args.all === true ? { all: true } : {}),\n },\n requireChatId(),\n );\n const response = await apiPost<TagsUnstageResponse>(\"/api/tags/draft-op/remove\", body);\n writeJson({\n ...response,\n hints: [\"Taken back: it does not apply when the chat is published. Live tags are unchanged.\"],\n });\n } catch (err) {\n failApi(err);\n }\n },\n});\n\nexport const tagsCommand = defineCommand({\n meta: {\n name: \"tags\",\n description: `Read the client's marketing/analytics tags (Meta pixel, GA4, Google Ads, GTM, Clarity, Hotjar, …) — production tags plus the changes staged in this chat.\n\nEvery tag change — create, edit, or delete — goes through the request_tag_input tool (baker_ui MCP server): propose one or more changes (each becomes a tab in one approval form), pre-fill the non-secret fields you know, and the user reviews, fills secrets, and approves or skips each. Secret values (accessToken, apiSecret, authorizationToken, apiKey, conversionToken, OAuth connections) never pass through the CLI or the chat.\n\nRefs: \\`baker tags list\\` prints each tag's ref — a real tag id, or tag_temp_* for creates staged in this chat. Use these refs as flow side-effect tagIds; they keep resolving after publish.\n\n\\`baker tags list\\` prints the JSON envelope (\\`--output md\\` to read it), with each tag's readable config (secrets excluded) — the Clarity projectId, GA4 measurementId, etc.; a custom \\`code\\` script shows as its size until \\`--full\\`. Reuse a stored value to pre-fill a follow-up change instead of asking the user for something already installed.\n\nTo take back a change this chat staged (before Publish), \\`baker tags unstage <ref>\\` — the ref \\`baker tags draft\\` prints — or \\`--all\\`. It never touches a live tag.\n\nExamples:\n baker tags list # production + staged, config + secret status, as the JSON envelope\n baker tags list --output md --full # readable, custom code scripts whole\n baker tags draft # review the staged changes awaiting publish\n baker tags unstage tag_temp_abc123 # take back one staged change\nFull guide: __tooling__/docs/tools/baker/tags.md`,\n },\n subCommands: {\n list: listCommand,\n draft: draftCommand,\n unstage: unstageCommand,\n },\n // Bare `baker tags` lists the effective tags. `args` stays so citty knows this\n // command's flags when it scans rawArgs for a subcommand name, and `default` (not\n // `run`) dispatches the bare invocation — citty falls through to `run` after a\n // subcommand, so a `run` here would also list on every `baker tags draft`.\n args: listArgs,\n default: \"list\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,qBAAqB;AAgB9B,IAAM,0BACJ;AACF,IAAM,wBACJ;AACF,IAAM,wBAAwB;AAE9B,eAAe;AAAA,EACb,SAAS;AAAA,EACT,aACE;AAAA,EACF,MAAM;AAAA,IACJ,QAAQ,EAAE,MAAM,UAAU,aAAa,yBAAyB,UAAU,OAAO,SAAS,OAAO;AAAA,IACjG,MAAM,EAAE,MAAM,W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