@koda-sl/baker-cli 0.370.0 → 0.372.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 (27) hide show
  1. package/README.md +23 -0
  2. package/dist/{chunk-L4QXAYIC.js → chunk-4ACU7GBN.js} +4 -4
  3. package/dist/{chunk-AI4HWQVN.js → chunk-FGHMWBUD.js} +193 -111
  4. package/dist/chunk-FGHMWBUD.js.map +1 -0
  5. package/dist/{chunk-2OKSJNLA.js → chunk-HJEMOSPH.js} +439 -2
  6. package/dist/chunk-HJEMOSPH.js.map +1 -0
  7. package/dist/{chunk-MZQC4LII.js → chunk-MF7YA62W.js} +3 -3
  8. package/dist/{chunk-XWHHYHKQ.js → chunk-VZEDAFAR.js} +2 -2
  9. package/dist/{chunk-FXVELNAS.js → chunk-ZI7TPBXB.js} +3 -3
  10. package/dist/cli.js +51 -304
  11. package/dist/cli.js.map +1 -1
  12. package/dist/{client-3DGBQ2H3.js → client-GR6YL3YX.js} +4 -4
  13. package/dist/engine/index.js +3 -3
  14. package/dist/{env-BSG7TY5Y.js → env-4P5HOGNA.js} +2 -2
  15. package/dist/{output-AT5SRVH7.js → output-KMEPFOFT.js} +5 -5
  16. package/dist/{shared-HZ44PY2F.js → shared-26NWGQ5G.js} +6 -6
  17. package/package.json +1 -1
  18. package/dist/chunk-2OKSJNLA.js.map +0 -1
  19. package/dist/chunk-AI4HWQVN.js.map +0 -1
  20. /package/dist/{chunk-L4QXAYIC.js.map → chunk-4ACU7GBN.js.map} +0 -0
  21. /package/dist/{chunk-MZQC4LII.js.map → chunk-MF7YA62W.js.map} +0 -0
  22. /package/dist/{chunk-XWHHYHKQ.js.map → chunk-VZEDAFAR.js.map} +0 -0
  23. /package/dist/{chunk-FXVELNAS.js.map → chunk-ZI7TPBXB.js.map} +0 -0
  24. /package/dist/{client-3DGBQ2H3.js.map → client-GR6YL3YX.js.map} +0 -0
  25. /package/dist/{env-BSG7TY5Y.js.map → env-4P5HOGNA.js.map} +0 -0
  26. /package/dist/{output-AT5SRVH7.js.map → output-KMEPFOFT.js.map} +0 -0
  27. /package/dist/{shared-HZ44PY2F.js.map → shared-26NWGQ5G.js.map} +0 -0
package/dist/cli.js CHANGED
@@ -55,6 +55,7 @@ import {
55
55
  promptMaxLength,
56
56
  requireCredentialsFromEnv,
57
57
  resolveConcurrency,
58
+ runFailureCode,
58
59
  runYtDlp,
59
60
  sha256Hex,
60
61
  spineInputFlags,
@@ -69,7 +70,7 @@ import {
69
70
  validateCanvasDeep,
70
71
  withoutCastName,
71
72
  ytDlpBlockSignal
72
- } from "./chunk-AI4HWQVN.js";
73
+ } from "./chunk-FGHMWBUD.js";
73
74
  import {
74
75
  csvOrJson,
75
76
  daysAgoIso,
@@ -79,7 +80,7 @@ import {
79
80
  resolveEffectiveStatus,
80
81
  statusFilterHints,
81
82
  todayIso
82
- } from "./chunk-L4QXAYIC.js";
83
+ } from "./chunk-4ACU7GBN.js";
83
84
  import {
84
85
  buildQueryCacheKey,
85
86
  cacheGet,
@@ -95,42 +96,50 @@ import {
95
96
  writeAdsJson,
96
97
  writeAdsOutput,
97
98
  writeJsonEnvelope
98
- } from "./chunk-FXVELNAS.js";
99
+ } from "./chunk-ZI7TPBXB.js";
99
100
  import {
100
101
  ApiError,
101
102
  apiGet,
102
103
  apiGetWithHeaders,
103
104
  apiPost,
104
105
  validateConvexId
105
- } from "./chunk-MZQC4LII.js";
106
+ } from "./chunk-MF7YA62W.js";
106
107
  import {
107
108
  installExitRecord,
108
109
  installStreamTaps,
109
110
  logInvocation
110
- } from "./chunk-XWHHYHKQ.js";
111
+ } from "./chunk-VZEDAFAR.js";
111
112
  import {
112
113
  adContentNormalizer,
113
114
  captureBudgetMs,
114
115
  captureProxyCredentials,
115
116
  captureVimeoCookie,
117
+ commandPathOf,
116
118
  compactImage,
117
119
  compactVideo,
120
+ findSchema,
118
121
  getEnv,
119
122
  hasOpenRouterKey,
123
+ installFieldMask,
120
124
  isProxyFailure,
125
+ listSchemas,
121
126
  openRouterKey,
122
127
  optionalChatId,
128
+ outputFlagForCommand,
123
129
  plannedRoutes,
124
130
  refuseNonPublicUrl,
131
+ refuseUnknownFlags,
132
+ registerSchema,
125
133
  requireChatId,
126
134
  resolveChatId,
127
135
  shouldEscalate,
136
+ takeFieldsFlag,
128
137
  testimonialNormalizer,
129
138
  videoNormalizer,
130
139
  winningAdNormalizer,
131
140
  writeJson,
132
141
  writeOutput
133
- } from "./chunk-2OKSJNLA.js";
142
+ } from "./chunk-HJEMOSPH.js";
134
143
 
135
144
  // src/cli.ts
136
145
  import { defineCommand as defineCommand248, runMain } from "citty";
@@ -171,30 +180,6 @@ import { defineCommand as defineCommand18 } from "citty";
171
180
  // src/commands/actions/claim.ts
172
181
  import { defineCommand } from "citty";
173
182
 
174
- // src/schemas.ts
175
- var registry = /* @__PURE__ */ new Map();
176
- function registerSchema(schema) {
177
- registry.set(schema.command, schema);
178
- }
179
- function listSchemas() {
180
- return [...registry.keys()];
181
- }
182
- function spellingKey(name) {
183
- return name.toLowerCase().replaceAll("-", "");
184
- }
185
- function resolveSchemaName(words2, names) {
186
- const joined = words2.join(".");
187
- if (names.includes(joined)) {
188
- return joined;
189
- }
190
- const matches = names.filter((name) => spellingKey(name) === spellingKey(joined));
191
- return matches.length === 1 ? matches[0] : void 0;
192
- }
193
- function findSchema(words2) {
194
- const name = resolveSchemaName(words2, listSchemas());
195
- return name === void 0 ? void 0 : registry.get(name);
196
- }
197
-
198
183
  // ../api/src/actions.ts
199
184
  import { z } from "zod";
200
185
  var actionStatusSchema = z.enum(["pending", "in_progress", "completed", "discarded"]);
@@ -26579,10 +26564,10 @@ Example: baker ads meta ads retag 120252158038400247 --url-tags "utm_source={{si
26579
26564
  }
26580
26565
  },
26581
26566
  run: async ({ args: args5 }) => {
26582
- const { apiPost: apiPost2 } = await import("./client-3DGBQ2H3.js");
26583
- const { requireChatId: requireChatId2 } = await import("./env-BSG7TY5Y.js");
26584
- const { writeJsonEnvelope: writeJsonEnvelope2 } = await import("./output-AT5SRVH7.js");
26585
- const { handleMetaError: handleMetaError2 } = await import("./shared-HZ44PY2F.js");
26567
+ const { apiPost: apiPost2 } = await import("./client-GR6YL3YX.js");
26568
+ const { requireChatId: requireChatId2 } = await import("./env-4P5HOGNA.js");
26569
+ const { writeJsonEnvelope: writeJsonEnvelope2 } = await import("./output-KMEPFOFT.js");
26570
+ const { handleMetaError: handleMetaError2 } = await import("./shared-26NWGQ5G.js");
26586
26571
  try {
26587
26572
  const accountId = bareAccountId2(args5);
26588
26573
  const urlTags = typeof args5["url-tags"] === "string" ? args5["url-tags"] : void 0;
@@ -26727,10 +26712,10 @@ function duplicateCommand2(entity, label) {
26727
26712
  replace: { type: "boolean", description: "Pause the original once the copy publishes" }
26728
26713
  },
26729
26714
  run: async ({ args: args5 }) => {
26730
- const { apiPost: apiPost2 } = await import("./client-3DGBQ2H3.js");
26731
- const { requireChatId: requireChatId2 } = await import("./env-BSG7TY5Y.js");
26732
- const { writeJsonEnvelope: writeJsonEnvelope2 } = await import("./output-AT5SRVH7.js");
26733
- const { handleMetaError: handleMetaError2 } = await import("./shared-HZ44PY2F.js");
26715
+ const { apiPost: apiPost2 } = await import("./client-GR6YL3YX.js");
26716
+ const { requireChatId: requireChatId2 } = await import("./env-4P5HOGNA.js");
26717
+ const { writeJsonEnvelope: writeJsonEnvelope2 } = await import("./output-KMEPFOFT.js");
26718
+ const { handleMetaError: handleMetaError2 } = await import("./shared-26NWGQ5G.js");
26734
26719
  try {
26735
26720
  const accountId = bareAccountId2(args5);
26736
26721
  const chatId = requireChatId2();
@@ -42468,14 +42453,14 @@ ${describeRewrites(healed.rewrites)}
42468
42453
  const failures = e.failures.map((f) => ({ node_id: f.nodeId, message: describeFailureReason(f.reason) }));
42469
42454
  if (poster) await poster.flush(failedPayload(e.message));
42470
42455
  process.stderr.write(
42471
- `${JSON.stringify({ ok: false, error: { code: "runtime", message: e.message, failures } }, null, 2)}
42456
+ `${JSON.stringify({ ok: false, error: { code: runFailureCode(e), message: e.message, failures } }, null, 2)}
42472
42457
  `
42473
42458
  );
42474
42459
  process.exit(1);
42475
42460
  }
42476
42461
  const msg = e instanceof Error ? e.message : String(e);
42477
42462
  if (poster) await poster.flush(failedPayload(msg));
42478
- process.stderr.write(`${JSON.stringify({ ok: false, error: { code: "runtime", message: msg } }, null, 2)}
42463
+ process.stderr.write(`${JSON.stringify({ ok: false, error: { code: runFailureCode(e), message: msg } }, null, 2)}
42479
42464
  `);
42480
42465
  process.exit(1);
42481
42466
  }
@@ -43312,6 +43297,15 @@ function resolvePlacements(placementsFlag, definitionPlatform) {
43312
43297
  message: `--placements "${flag}" is not a valid placement set. Use one of: ${AD_FORMAT_PLATFORMS.join(", ")}, or "none" for a single base ad.`
43313
43298
  };
43314
43299
  }
43300
+ async function validateScaffoldedStaticAd(canvas, canvasDir) {
43301
+ const validation = await validateCanvasDeep(resolveRelativeCanvasPaths(canvas, canvasDir), defaultRegistry());
43302
+ if (validation.ok) return { blocking: [], hints: [], estimatedCredits: validation.estimatedCredits };
43303
+ const overCap = validation.issues.filter((i) => i.code === "PROMPT_OVER_MODEL_LIMIT");
43304
+ return {
43305
+ blocking: validation.issues.filter((i) => i.code !== "PROMPT_OVER_MODEL_LIMIT"),
43306
+ hints: overCap.map((i) => `${i.code}: ${i.message} Trim prompt.json, then \`baker canvas validate\`.`)
43307
+ };
43308
+ }
43315
43309
  function regionCount(layout) {
43316
43310
  const regions = layout?.regions;
43317
43311
  return Array.isArray(regions) ? regions.length : 0;
@@ -43503,10 +43497,10 @@ var scaffoldStaticAdCommand = defineCommand114({
43503
43497
  } catch (e) {
43504
43498
  return fail3("scaffold", e instanceof Error ? e.message : String(e));
43505
43499
  }
43506
- const validation = await validateCanvasDeep(canvas, defaultRegistry());
43507
- if (!validation.ok) {
43500
+ const validation = await validateScaffoldedStaticAd(canvas, path21.dirname(outPath));
43501
+ if (validation.blocking.length > 0) {
43508
43502
  process.stderr.write(
43509
- `${JSON.stringify({ ok: false, error: { code: "validation", issues: validation.issues } }, null, 2)}
43503
+ `${JSON.stringify({ ok: false, error: { code: "validation", issues: validation.blocking } }, null, 2)}
43510
43504
  `
43511
43505
  );
43512
43506
  process.exit(2);
@@ -43540,6 +43534,12 @@ var scaffoldStaticAdCommand = defineCommand114({
43540
43534
  sourceSha: await computeSourceSha(outPath)
43541
43535
  });
43542
43536
  }
43537
+ const hints2 = [
43538
+ ...uncast.length ? [
43539
+ `NOT CAST: ${uncast.map((h) => `\`${h}\``).join(", ")} \u2014 the element selection found fewer people than avatars passed, so ${uncast.length === 1 ? "this avatar plays" : "these avatars play"} nobody in this ad. Tell the user who is cast and who is not.`
43540
+ ] : [],
43541
+ ...validation.hints
43542
+ ];
43543
43543
  process.stdout.write(
43544
43544
  `${JSON.stringify(
43545
43545
  {
@@ -43549,11 +43549,7 @@ var scaffoldStaticAdCommand = defineCommand114({
43549
43549
  definition_path: definitionPath ?? void 0,
43550
43550
  source_reference: durableSourceUrl ?? void 0,
43551
43551
  output: canvas.output,
43552
- ...uncast.length ? {
43553
- hints: [
43554
- `NOT CAST: ${uncast.map((h) => `\`${h}\``).join(", ")} \u2014 the element selection found fewer people than avatars passed, so ${uncast.length === 1 ? "this avatar plays" : "these avatars play"} nobody in this ad. Tell the user who is cast and who is not.`
43555
- ]
43556
- } : {},
43552
+ ...hints2.length ? { hints: hints2 } : {},
43557
43553
  models: { describe: describeModel, select: selectModel, layout: layoutModel, gen: opts.genModel },
43558
43554
  aspect_ratio: report.aspect_ratio,
43559
43555
  placements: report.placements,
@@ -45838,7 +45834,7 @@ import { defineCommand as defineCommand118 } from "citty";
45838
45834
  var validateCommand = defineCommand118({
45839
45835
  meta: {
45840
45836
  name: "validate",
45841
- description: "Validate a canvas JSON file (no execution). Includes a per-node cost preview and runs each node's deep validators (composition meta checks for hyperframe_render/_snapshot)."
45837
+ description: "Validate a canvas JSON file (no execution). Includes a per-node cost preview and runs each node's deep validators (composition meta checks for hyperframe_render/_snapshot), and measures each generator prompt with its {{slots}} filled against the model's character cap (PROMPT_OVER_MODEL_LIMIT)."
45842
45838
  },
45843
45839
  args: { file: { type: "positional", required: true, description: "Path to canvas JSON" } },
45844
45840
  async run({ args: args5 }) {
@@ -69371,261 +69367,6 @@ Full guide: __tooling__/docs/tools/baker/winning-ads.md`
69371
69367
  }
69372
69368
  });
69373
69369
 
69374
- // src/unknown-flags.ts
69375
- var ALWAYS_ACCEPTED = /* @__PURE__ */ new Set(["help", "h", "version"]);
69376
- function subCommandsOf(command) {
69377
- const sub = command.subCommands;
69378
- return sub && typeof sub === "object" ? sub : null;
69379
- }
69380
- function argsOf(command) {
69381
- const args5 = command.args;
69382
- return args5 && typeof args5 === "object" ? args5 : null;
69383
- }
69384
- function resolveCommand2(root, argv) {
69385
- let command = root;
69386
- for (const token of argv) {
69387
- if (token === "--" || token.startsWith("-")) {
69388
- break;
69389
- }
69390
- const subCommands = subCommandsOf(command);
69391
- if (!subCommands) {
69392
- break;
69393
- }
69394
- const next = subCommands[token];
69395
- if (next === void 0) {
69396
- break;
69397
- }
69398
- if (typeof next !== "object") {
69399
- return { command, resolved: false };
69400
- }
69401
- command = next;
69402
- }
69403
- return { command, resolved: true };
69404
- }
69405
- function typeOf(def) {
69406
- return def && typeof def === "object" ? def.type : void 0;
69407
- }
69408
- function acceptedNames(command) {
69409
- const args5 = argsOf(command);
69410
- if (!args5) {
69411
- return null;
69412
- }
69413
- const names = new Set(ALWAYS_ACCEPTED);
69414
- for (const [name, def] of Object.entries(args5)) {
69415
- if (typeOf(def) === "positional") {
69416
- continue;
69417
- }
69418
- for (const spelling of [name, kebab(name), camel(name)]) {
69419
- names.add(spelling);
69420
- if (typeOf(def) === "boolean") {
69421
- names.add(`no-${spelling}`);
69422
- }
69423
- }
69424
- }
69425
- return names;
69426
- }
69427
- function kebab(name) {
69428
- return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
69429
- }
69430
- function camel(name) {
69431
- return name.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
69432
- }
69433
- function findUnknownFlags(root, argv) {
69434
- const { command, resolved } = resolveCommand2(root, argv);
69435
- if (!resolved) {
69436
- return [];
69437
- }
69438
- const accepted = acceptedNames(command);
69439
- if (!accepted) {
69440
- return [];
69441
- }
69442
- const unknown = [];
69443
- for (const token of argv) {
69444
- if (token === "--") {
69445
- break;
69446
- }
69447
- if (!token.startsWith("--")) {
69448
- continue;
69449
- }
69450
- const name = token.slice(2).split("=")[0] ?? "";
69451
- if (name.length > 0 && !accepted.has(name) && !unknown.includes(token)) {
69452
- unknown.push(token);
69453
- }
69454
- }
69455
- return unknown;
69456
- }
69457
- var SYNONYMS = {
69458
- from: ["start-date", "start", "since"],
69459
- since: ["start-date", "start"],
69460
- start: ["start-date", "since"],
69461
- to: ["end-date", "end", "until"],
69462
- until: ["end-date", "end"],
69463
- end: ["end-date", "until"],
69464
- path: ["landing"],
69465
- url: ["landing"]
69466
- };
69467
- function closestFlag(unknown, command) {
69468
- const accepted = acceptedNames(command);
69469
- if (!accepted) {
69470
- return null;
69471
- }
69472
- const name = unknown.replace(/^--/, "").split("=")[0] ?? "";
69473
- const synonym = SYNONYMS[name]?.find((candidate) => accepted.has(candidate));
69474
- if (synonym) {
69475
- return `--${synonym}`;
69476
- }
69477
- const scored = [...accepted].filter((candidate) => !ALWAYS_ACCEPTED.has(candidate)).map((candidate) => ({
69478
- candidate,
69479
- prefix: sharedPrefix(name, candidate),
69480
- distance: editDistance(name, candidate)
69481
- })).filter(({ prefix, distance }) => prefix >= 4 || distance <= typoBudget(name)).sort((a, b) => b.prefix - a.prefix || a.distance - b.distance);
69482
- return scored[0] ? `--${scored[0].candidate}` : null;
69483
- }
69484
- function typoBudget(name) {
69485
- return Math.max(1, Math.floor(name.length / 3));
69486
- }
69487
- function sharedPrefix(a, b) {
69488
- let i = 0;
69489
- while (i < a.length && i < b.length && a[i] === b[i]) {
69490
- i++;
69491
- }
69492
- return i;
69493
- }
69494
- function editDistance(a, b) {
69495
- let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
69496
- for (let i = 1; i <= a.length; i++) {
69497
- const current = [i];
69498
- for (let j = 1; j <= b.length; j++) {
69499
- const substitution = (previous[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1);
69500
- current.push(Math.min((previous[j] ?? 0) + 1, (current[j - 1] ?? 0) + 1, substitution));
69501
- }
69502
- previous = current;
69503
- }
69504
- return previous[b.length] ?? 0;
69505
- }
69506
- function commandFor(root, argv) {
69507
- const { command, resolved } = resolveCommand2(root, argv);
69508
- return resolved ? command : null;
69509
- }
69510
- function suggestFlag(unknown, command) {
69511
- const flag = closestFlag(unknown, command);
69512
- if (!flag) {
69513
- return null;
69514
- }
69515
- const args5 = argsOf(command) ?? {};
69516
- const name = flag.slice(2);
69517
- const def = args5[name] ?? args5[camel(name)];
69518
- const described = def && typeof def === "object" ? def.description : void 0;
69519
- const description = typeof described === "string" ? described.split(/(?<!\b(?:e\.g|i\.e|vs))\.\s/)[0]?.trim().replace(/\.$/, "") : "";
69520
- return description ? { flag, description } : { flag };
69521
- }
69522
- function suggestionText(suggestion) {
69523
- if (!suggestion) {
69524
- return "";
69525
- }
69526
- return suggestion.description ? `Did you mean ${suggestion.flag}? It is described as: ${suggestion.description}. ` : `Did you mean ${suggestion.flag}? `;
69527
- }
69528
- var OUTPUT_EXPLANATION = "This command has no --output option: `--output json` is accepted by every command that prints the JSON envelope, and md or files only where `baker schema` lists `output`. Drop the option and read the default output. ";
69529
- function unknownFlagEnvelope(unknown, commandPath, suggestion, hasSchema) {
69530
- const list = unknown.join(", ");
69531
- return {
69532
- ok: false,
69533
- error: {
69534
- code: "UNKNOWN_ARGUMENT",
69535
- message: `${list} ${unknown.length > 1 ? "are not options" : "is not an option"} of \`baker ${commandPath}\`.`,
69536
- fix: {
69537
- action: hasSchema ? "check_schema" : "check_help",
69538
- explanation: (unknown.some((flag) => flag === "--output" || flag.startsWith("--output=")) ? OUTPUT_EXPLANATION : "") + suggestionText(suggestion) + `Run \`${hasSchema ? `baker schema ${commandPath}` : `baker ${commandPath} --help`}\` to see every option this command takes. Do not re-run the same call: until this version an unrecognised option was accepted and ignored, so a command that looked like it had filtered or narrowed the result was in fact answering the unfiltered question.`
69539
- },
69540
- retryable: false
69541
- }
69542
- };
69543
- }
69544
- function commandPathOf(root, argv) {
69545
- const path48 = [];
69546
- let command = root;
69547
- for (const token of argv) {
69548
- if (token === "--" || token.startsWith("-")) {
69549
- break;
69550
- }
69551
- const subCommands = subCommandsOf(command);
69552
- const next = subCommands?.[token];
69553
- if (next === void 0 || typeof next !== "object") {
69554
- break;
69555
- }
69556
- path48.push(token);
69557
- command = next;
69558
- }
69559
- return path48.join(" ");
69560
- }
69561
- function refuseUnknownFlags(root, argv) {
69562
- const unknown = findUnknownFlags(root, argv);
69563
- if (unknown.length === 0) {
69564
- return;
69565
- }
69566
- const command = commandFor(root, argv);
69567
- const first = unknown[0];
69568
- const suggestion = command && first ? suggestFlag(first, command) : null;
69569
- const path48 = commandPathOf(root, argv);
69570
- process.stdout.write(
69571
- `${JSON.stringify(unknownFlagEnvelope(unknown, path48, suggestion, findSchema(path48.split(" ")) !== void 0), null, 2)}
69572
- `
69573
- );
69574
- process.exit(1);
69575
- }
69576
-
69577
- // src/output-flag.ts
69578
- var FLAG = "--output";
69579
- var ENVELOPE = "json";
69580
- var PRINTS_NO_ENVELOPE = /* @__PURE__ */ new Set([
69581
- "analytics sending-events",
69582
- "canvas run",
69583
- "canvas rerun",
69584
- "canvas sync-definition"
69585
- ]);
69586
- function declaredArg(command, name) {
69587
- const args5 = command.args;
69588
- if (!args5 || typeof args5 !== "object" || !(name in args5)) {
69589
- return null;
69590
- }
69591
- const def = args5[name];
69592
- return def && typeof def === "object" ? def : {};
69593
- }
69594
- function envelopeRequests(argv) {
69595
- const end = argv.indexOf("--");
69596
- const limit = end === -1 ? argv.length : end;
69597
- const found = [];
69598
- for (let index = 0; index < limit; index++) {
69599
- const token = argv[index];
69600
- if (token === `${FLAG}=${ENVELOPE}`) {
69601
- found.push({ index, length: 1 });
69602
- } else if (token === FLAG && argv[index + 1] === ENVELOPE && index + 1 < limit) {
69603
- found.push({ index, length: 2 });
69604
- index++;
69605
- }
69606
- }
69607
- return found;
69608
- }
69609
- function outputFlagForCommand(root, argv) {
69610
- const requests = envelopeRequests(argv);
69611
- if (requests.length === 0) {
69612
- return argv;
69613
- }
69614
- const command = commandFor(root, argv);
69615
- if (!command || declaredArg(command, "output") || PRINTS_NO_ENVELOPE.has(commandPathOf(root, argv))) {
69616
- return argv;
69617
- }
69618
- const jsonSwitch = declaredArg(command, "json")?.type === "boolean";
69619
- const dropped = new Set(requests.flatMap(({ index, length }) => length === 2 ? [index, index + 1] : [index]));
69620
- const first = requests[0]?.index;
69621
- return argv.flatMap((token, index) => {
69622
- if (!dropped.has(index)) {
69623
- return [token];
69624
- }
69625
- return jsonSwitch && index === first ? ["--json"] : [];
69626
- });
69627
- }
69628
-
69629
69370
  // src/version.ts
69630
69371
  import { readFileSync as readFileSync21 } from "fs";
69631
69372
  function packageJsonUrl() {
@@ -69652,6 +69393,7 @@ var main = defineCommand248({
69652
69393
  Auth: Set BAKER_API_KEY (starts with bk_) and BAKER_API_URL environment variables.
69653
69394
  Chat: Set BAKER_CHAT_ID for action and scheduled-agent commands that stage changes against a chat.
69654
69395
  Output: All commands return JSON envelopes: { ok: true, data: ... } or { ok: false, error: { code, message } }.
69396
+ Fields: --fields a,b,c keeps only those keys of each record in data, on every command that prints the envelope.
69655
69397
  Formats: --output json works on every command that prints the envelope. --output md|files only where 'baker schema <command>' lists output. (The research commands additionally accept csv and jsonl.)
69656
69398
  Introspection: Run 'baker schema <command>' to inspect argument schemas.`
69657
69399
  },
@@ -69691,6 +69433,11 @@ installStreamTaps();
69691
69433
  logInvocation(process.argv.slice(2));
69692
69434
  installExitRecord();
69693
69435
  process.argv = [...process.argv.slice(0, 2), ...outputFlagForCommand(main, process.argv.slice(2))];
69436
+ var fieldsFlag = takeFieldsFlag(main, process.argv.slice(2));
69437
+ if (fieldsFlag.fields) {
69438
+ process.argv = [...process.argv.slice(0, 2), ...fieldsFlag.argv];
69439
+ installFieldMask(fieldsFlag.fields, commandPathOf(main, fieldsFlag.argv));
69440
+ }
69694
69441
  refuseUnknownFlags(main, process.argv.slice(2));
69695
69442
  process.argv = [...process.argv.slice(0, 2), ...cacheFlagForParser(process.argv.slice(2))];
69696
69443
  runMain(main);