@koda-sl/baker-cli 0.530.0 → 0.531.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.
- package/README.md +4 -0
- package/dist/{avatars-IJQOWSFC.js → avatars-K7RBSMIJ.js} +1 -1
- package/dist/{brief-ZDHUBPV5.js → brief-SLTB3EPO.js} +15 -15
- package/dist/{canvas-AZ47PNYZ.js → canvas-2VRPGRND.js} +11 -11
- package/dist/{chunk-5G225R4A.js → chunk-3H5MJOG2.js} +2 -2
- package/dist/{chunk-BTVK3CU7.js → chunk-4ULRDQVD.js} +3 -1
- package/dist/{chunk-BTVK3CU7.js.map → chunk-4ULRDQVD.js.map} +1 -1
- package/dist/{chunk-KDNOMRJA.js → chunk-5EF7ZLXA.js} +3 -3
- package/dist/{chunk-3N2KAOVM.js → chunk-CSCHS3JG.js} +7 -7
- package/dist/{chunk-7B73TSKJ.js → chunk-ERRTBCDW.js} +3 -3
- package/dist/{chunk-7ODQ6ZID.js → chunk-EZBZU6N7.js} +3 -3
- package/dist/{chunk-HZ3RXKR4.js → chunk-FVZL2YC5.js} +5 -5
- package/dist/{chunk-FX3MXXYD.js → chunk-GDQJG4BO.js} +2 -2
- package/dist/{chunk-PTK7AFEE.js → chunk-HAJYFRXL.js} +2 -2
- package/dist/{chunk-UXZZ5AEO.js → chunk-PGBZ73UZ.js} +2 -2
- package/dist/{chunk-7OVCUTEL.js → chunk-XWO6CXNG.js} +2 -2
- package/dist/{chunk-WQKBEC4I.js → chunk-Y25HSPRJ.js} +2 -2
- package/dist/cli.js +15 -14
- package/dist/cli.js.map +1 -1
- package/dist/{create-LPD3JAIW.js → create-PYP3QWTL.js} +3 -3
- package/dist/{creatives-QFSIIFXB.js → creatives-ANTJUTIE.js} +6 -6
- package/dist/{critique-OK2ENBOA.js → critique-MZUTDK4V.js} +5 -5
- package/dist/{delete-FK3A36WP.js → delete-3H6YH4YK.js} +3 -3
- package/dist/{feedback-ZBEZIIPT.js → feedback-TJRYTOR3.js} +8 -8
- package/dist/{feedback-record-CZVSPZUR.js → feedback-record-7IAJI5IY.js} +11 -11
- package/dist/{flows-CAOMVQYZ.js → flows-LL5SPPIK.js} +1 -1
- package/dist/{get-25KJJTO6.js → get-XPJ4BZGP.js} +3 -3
- package/dist/{history-DTQVPVFA.js → history-RD2YMNNL.js} +3 -3
- package/dist/{images-K7JQ3ORB.js → images-XP4TKE2F.js} +1 -1
- package/dist/{inspiration-KAXPRINY.js → inspiration-D75DO3MD.js} +1 -1
- package/dist/knowledge-PKXPN4RV.js +195 -0
- package/dist/knowledge-PKXPN4RV.js.map +1 -0
- package/dist/{landing-BFMRM3HA.js → landing-O2ZUIUGE.js} +2 -2
- package/dist/{list-6PIJGN4M.js → list-OZCU2T22.js} +3 -3
- package/dist/{make-N5LVJSZD.js → make-T6HLXIYY.js} +21 -21
- package/dist/{posts-BDMC644W.js → posts-ILAFADBW.js} +1 -1
- package/dist/{rerun-HUFJUOEV.js → rerun-UPDIXTEL.js} +9 -9
- package/dist/{run-CIXOJA3K.js → run-4UIPMCSN.js} +3 -3
- package/dist/{run-7OCCCNJ4.js → run-GACZDI6Q.js} +9 -9
- package/dist/{scaffold-ad-7ADCDQBK.js → scaffold-ad-Z2HSN4PE.js} +6 -6
- package/dist/{scaffold-static-ad-TV5OWISA.js → scaffold-static-ad-ODZGTIM5.js} +11 -11
- package/dist/{scaffold-video-LLBDO546.js → scaffold-video-EHGAMEEP.js} +6 -6
- package/dist/{scheduled-agents-BGMWNCAU.js → scheduled-agents-4VY4CAA2.js} +11 -11
- package/dist/{schema-NCJTDRRV.js → schema-EYGPETLF.js} +2 -2
- package/dist/{select-BRH4QLWU.js → select-FCQUYBKV.js} +7 -7
- package/dist/{set-prompt-SYWNE4CS.js → set-prompt-IBAG6BDA.js} +5 -5
- package/dist/{sources-CGXHNWJM.js → sources-K2LILGTW.js} +1 -1
- package/dist/{stale-QNIJZTGD.js → stale-VR5QAYB6.js} +6 -6
- package/dist/{studio-NRWLXOFZ.js → studio-3D42TUJX.js} +1 -1
- package/dist/{sync-definition-EGHEQ57K.js → sync-definition-MZUJOJYI.js} +6 -6
- package/dist/{targets-KZBMOZUE.js → targets-LQ7HGI73.js} +3 -3
- package/dist/{testimonials-2NQMY23B.js → testimonials-Z2KOOMVH.js} +2 -2
- package/dist/{translate-YGHRSEX6.js → translate-II4JY2XW.js} +8 -8
- package/dist/{triggers-35UVEDXF.js → triggers-Z3LV3KJR.js} +3 -3
- package/dist/{unstage-E2257FEP.js → unstage-QXOL5DXZ.js} +3 -3
- package/dist/{update-GTXZRINC.js → update-UE4XVBKL.js} +3 -3
- package/dist/{validate-JX4FT7PL.js → validate-BCK22BQL.js} +7 -7
- package/dist/{videos-EHDZ46UQ.js → videos-YCQVOOFE.js} +1 -1
- package/dist/{winning-ads-H7ZE5AQW.js → winning-ads-7X5EWSJX.js} +1 -1
- package/package.json +1 -1
- /package/dist/{avatars-IJQOWSFC.js.map → avatars-K7RBSMIJ.js.map} +0 -0
- /package/dist/{brief-ZDHUBPV5.js.map → brief-SLTB3EPO.js.map} +0 -0
- /package/dist/{canvas-AZ47PNYZ.js.map → canvas-2VRPGRND.js.map} +0 -0
- /package/dist/{chunk-5G225R4A.js.map → chunk-3H5MJOG2.js.map} +0 -0
- /package/dist/{chunk-KDNOMRJA.js.map → chunk-5EF7ZLXA.js.map} +0 -0
- /package/dist/{chunk-3N2KAOVM.js.map → chunk-CSCHS3JG.js.map} +0 -0
- /package/dist/{chunk-7B73TSKJ.js.map → chunk-ERRTBCDW.js.map} +0 -0
- /package/dist/{chunk-7ODQ6ZID.js.map → chunk-EZBZU6N7.js.map} +0 -0
- /package/dist/{chunk-HZ3RXKR4.js.map → chunk-FVZL2YC5.js.map} +0 -0
- /package/dist/{chunk-FX3MXXYD.js.map → chunk-GDQJG4BO.js.map} +0 -0
- /package/dist/{chunk-PTK7AFEE.js.map → chunk-HAJYFRXL.js.map} +0 -0
- /package/dist/{chunk-UXZZ5AEO.js.map → chunk-PGBZ73UZ.js.map} +0 -0
- /package/dist/{chunk-7OVCUTEL.js.map → chunk-XWO6CXNG.js.map} +0 -0
- /package/dist/{chunk-WQKBEC4I.js.map → chunk-Y25HSPRJ.js.map} +0 -0
- /package/dist/{create-LPD3JAIW.js.map → create-PYP3QWTL.js.map} +0 -0
- /package/dist/{creatives-QFSIIFXB.js.map → creatives-ANTJUTIE.js.map} +0 -0
- /package/dist/{critique-OK2ENBOA.js.map → critique-MZUTDK4V.js.map} +0 -0
- /package/dist/{delete-FK3A36WP.js.map → delete-3H6YH4YK.js.map} +0 -0
- /package/dist/{feedback-ZBEZIIPT.js.map → feedback-TJRYTOR3.js.map} +0 -0
- /package/dist/{feedback-record-CZVSPZUR.js.map → feedback-record-7IAJI5IY.js.map} +0 -0
- /package/dist/{flows-CAOMVQYZ.js.map → flows-LL5SPPIK.js.map} +0 -0
- /package/dist/{get-25KJJTO6.js.map → get-XPJ4BZGP.js.map} +0 -0
- /package/dist/{history-DTQVPVFA.js.map → history-RD2YMNNL.js.map} +0 -0
- /package/dist/{images-K7JQ3ORB.js.map → images-XP4TKE2F.js.map} +0 -0
- /package/dist/{inspiration-KAXPRINY.js.map → inspiration-D75DO3MD.js.map} +0 -0
- /package/dist/{landing-BFMRM3HA.js.map → landing-O2ZUIUGE.js.map} +0 -0
- /package/dist/{list-6PIJGN4M.js.map → list-OZCU2T22.js.map} +0 -0
- /package/dist/{make-N5LVJSZD.js.map → make-T6HLXIYY.js.map} +0 -0
- /package/dist/{posts-BDMC644W.js.map → posts-ILAFADBW.js.map} +0 -0
- /package/dist/{rerun-HUFJUOEV.js.map → rerun-UPDIXTEL.js.map} +0 -0
- /package/dist/{run-CIXOJA3K.js.map → run-4UIPMCSN.js.map} +0 -0
- /package/dist/{run-7OCCCNJ4.js.map → run-GACZDI6Q.js.map} +0 -0
- /package/dist/{scaffold-ad-7ADCDQBK.js.map → scaffold-ad-Z2HSN4PE.js.map} +0 -0
- /package/dist/{scaffold-static-ad-TV5OWISA.js.map → scaffold-static-ad-ODZGTIM5.js.map} +0 -0
- /package/dist/{scaffold-video-LLBDO546.js.map → scaffold-video-EHGAMEEP.js.map} +0 -0
- /package/dist/{scheduled-agents-BGMWNCAU.js.map → scheduled-agents-4VY4CAA2.js.map} +0 -0
- /package/dist/{schema-NCJTDRRV.js.map → schema-EYGPETLF.js.map} +0 -0
- /package/dist/{select-BRH4QLWU.js.map → select-FCQUYBKV.js.map} +0 -0
- /package/dist/{set-prompt-SYWNE4CS.js.map → set-prompt-IBAG6BDA.js.map} +0 -0
- /package/dist/{sources-CGXHNWJM.js.map → sources-K2LILGTW.js.map} +0 -0
- /package/dist/{stale-QNIJZTGD.js.map → stale-VR5QAYB6.js.map} +0 -0
- /package/dist/{studio-NRWLXOFZ.js.map → studio-3D42TUJX.js.map} +0 -0
- /package/dist/{sync-definition-EGHEQ57K.js.map → sync-definition-MZUJOJYI.js.map} +0 -0
- /package/dist/{targets-KZBMOZUE.js.map → targets-LQ7HGI73.js.map} +0 -0
- /package/dist/{testimonials-2NQMY23B.js.map → testimonials-Z2KOOMVH.js.map} +0 -0
- /package/dist/{translate-YGHRSEX6.js.map → translate-II4JY2XW.js.map} +0 -0
- /package/dist/{triggers-35UVEDXF.js.map → triggers-Z3LV3KJR.js.map} +0 -0
- /package/dist/{unstage-E2257FEP.js.map → unstage-QXOL5DXZ.js.map} +0 -0
- /package/dist/{update-GTXZRINC.js.map → update-UE4XVBKL.js.map} +0 -0
- /package/dist/{validate-JX4FT7PL.js.map → validate-BCK22BQL.js.map} +0 -0
- /package/dist/{videos-EHDZ46UQ.js.map → videos-YCQVOOFE.js.map} +0 -0
- /package/dist/{winning-ads-H7ZE5AQW.js.map → winning-ads-7X5EWSJX.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
agentProfile,
|
|
9
9
|
applyAgentProfile,
|
|
10
10
|
loadCommands
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-4ULRDQVD.js";
|
|
12
12
|
import {
|
|
13
13
|
installExitRecord,
|
|
14
14
|
installStreamTaps,
|
|
@@ -213,7 +213,7 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`
|
|
|
213
213
|
subCommands: {
|
|
214
214
|
capabilities: () => import("./capabilities-BEZXR2FZ.js").then((m) => m.capabilitiesCommand),
|
|
215
215
|
actions: () => import("./actions-33IZOT5C.js").then((m) => m.actionsCommand),
|
|
216
|
-
"scheduled-agents": () => import("./scheduled-agents-
|
|
216
|
+
"scheduled-agents": () => import("./scheduled-agents-4VY4CAA2.js").then((m) => m.scheduledAgentsCommand),
|
|
217
217
|
ads: () => import("./ads-7TEPA4KZ.js").then((m) => m.adsCommand),
|
|
218
218
|
brand: () => import("./brand-GBP4OEJI.js").then((m) => m.brandCommand),
|
|
219
219
|
analytics: () => import("./analytics-XDWBEY57.js").then((m) => m.analyticsCommand),
|
|
@@ -222,16 +222,17 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`
|
|
|
222
222
|
gsc: () => import("./gsc-HI2KXDEU.js").then((m) => m.gscCommand),
|
|
223
223
|
research: () => import("./research-ELM3KHGE.js").then((m) => m.researchCommand),
|
|
224
224
|
decide: () => import("./decide-X2UAKYXK.js").then((m) => m.decideCommand),
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
knowledge: () => import("./knowledge-PKXPN4RV.js").then((m) => m.knowledgeCommand),
|
|
226
|
+
creatives: () => import("./creatives-ANTJUTIE.js").then((m) => m.creativesCommand),
|
|
227
|
+
flows: () => import("./flows-LL5SPPIK.js").then((m) => m.flowsCommand),
|
|
227
228
|
funnel: () => import("./funnel-XIZROHV7.js").then((m) => m.funnelCommand),
|
|
228
|
-
images: () => import("./images-
|
|
229
|
-
studio: () => import("./studio-
|
|
230
|
-
avatars: () => import("./avatars-
|
|
231
|
-
landing: () => import("./landing-
|
|
232
|
-
videos: () => import("./videos-
|
|
233
|
-
testimonials: () => import("./testimonials-
|
|
234
|
-
canvas: () => import("./canvas-
|
|
229
|
+
images: () => import("./images-XP4TKE2F.js").then((m) => m.imagesCommand),
|
|
230
|
+
studio: () => import("./studio-3D42TUJX.js").then((m) => m.studioCommand),
|
|
231
|
+
avatars: () => import("./avatars-K7RBSMIJ.js").then((m) => m.avatarsCommand),
|
|
232
|
+
landing: () => import("./landing-O2ZUIUGE.js").then((m) => m.landingCommand),
|
|
233
|
+
videos: () => import("./videos-YCQVOOFE.js").then((m) => m.videosCommand),
|
|
234
|
+
testimonials: () => import("./testimonials-Z2KOOMVH.js").then((m) => m.testimonialsCommand),
|
|
235
|
+
canvas: () => import("./canvas-2VRPGRND.js").then((m) => m.canvasCommand),
|
|
235
236
|
tags: () => import("./tags-JHT3Q6VO.js").then((m) => m.tagsCommand),
|
|
236
237
|
"tag-manager": () => import("./tag-manager-LU4GAZ6R.js").then((m) => m.tagManagerCommand),
|
|
237
238
|
chats: () => import("./chats-AN52YVBT.js").then((m) => m.chatsCommand),
|
|
@@ -241,15 +242,15 @@ Introspection: Run 'baker schema <command>' to inspect argument schemas.`
|
|
|
241
242
|
activecampaign: () => import("./activecampaign-BV5GZFVR.js").then((m) => m.activecampaignCommand),
|
|
242
243
|
accounts: () => import("./accounts-MHPNZW3W.js").then((m) => m.accountsCommand),
|
|
243
244
|
shopify: () => import("./shopify-7LDHCWUQ.js").then((m) => m.shopifyCommand),
|
|
244
|
-
"winning-ads": () => import("./winning-ads-
|
|
245
|
+
"winning-ads": () => import("./winning-ads-7X5EWSJX.js").then((m) => m.winningAdsCommand),
|
|
245
246
|
"media-sources": () => import("./media-sources-7R7FO53Y.js").then((m) => m.mediaSourcesCommand),
|
|
246
|
-
posts: () => import("./posts-
|
|
247
|
+
posts: () => import("./posts-ILAFADBW.js").then((m) => m.postsCommand),
|
|
247
248
|
site: () => import("./site-I3NFMPJB.js").then((m) => m.siteCommand),
|
|
248
249
|
"lead-routes": () => import("./lead-routes-WVXWVG62.js").then((m) => m.leadRoutesCommand),
|
|
249
250
|
mcp: () => import("./mcp-RSW7KAWP.js").then((m) => m.mcpCommand),
|
|
250
251
|
"setup-links": () => import("./setup-links-4STQ5B4P.js").then((m) => m.setupLinksCommand),
|
|
251
252
|
organization: () => import("./organization-A4NFWWWI.js").then((m) => m.organizationCommand),
|
|
252
|
-
schema: () => import("./schema-
|
|
253
|
+
schema: () => import("./schema-EYGPETLF.js").then((m) => m.schemaCommand)
|
|
253
254
|
}
|
|
254
255
|
});
|
|
255
256
|
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/closed-pipe.ts","../src/company-flag.ts","../src/full-flag.ts","../src/help-output.ts","../src/root-command.ts","../src/version.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { runCommand, runMain } from \"citty\";\nimport { agentProfile, applyAgentProfile } from \"./agent-profile.ts\";\nimport { cacheFlagForCommand, cacheFlagForParser, normalizeCacheFlag } from \"./cache-flag.ts\";\nimport { exitQuietlyOnClosedPipe } from \"./closed-pipe.ts\";\nimport { loadCommands } from \"./command-loading.ts\";\nimport { takeCompanyFlag } from \"./company-flag.ts\";\nimport { installExitRecord, installStreamTaps, logInvocation } from \"./debugLog.ts\";\nimport { setTargetCompany } from \"./env.ts\";\nimport { installFieldMask, takeFieldsFlag } from \"./field-mask.ts\";\nimport { installFullNote, takeFullFlag } from \"./full-flag.ts\";\nimport { printHelpTo } from \"./help-output.ts\";\nimport { writeJson } from \"./output.ts\";\nimport { asksForEnvelopeAlone, envelopeAloneOnStdout, outputFlagForCommand } from \"./output-flag.ts\";\nimport { rootCommand } from \"./root-command.ts\";\nimport { registerCommandTree } from \"./schemas.ts\";\nimport { commandPathOf, parseRefusalEnvelope, refuseStrayPositionals, refuseUnknownFlags } from \"./unknown-flags.ts\";\n\nconst main = rootCommand;\n// The call as typed, before the rewrites below: a refusal's corrected call is built from it.\nconst typedArgv = process.argv.slice(2);\n\nawait loadCommands(main, process.argv.slice(2));\nregisterCommandTree(main);\n\nexitQuietlyOnClosedPipe(process.stdout, (code) => process.exit(code));\n\n// The legacy `--skip-cache` spelling becomes `--no-cache` before anything reads\n// argv — citty parses `process.argv` itself, so the rewrite has to land there.\nprocess.argv = [...process.argv.slice(0, 2), ...normalizeCacheFlag(process.argv.slice(2))];\n\n// When BAKER_DEBUG_LOG is set, mirror all output and record the invocation\n// before any command runs. No-op otherwise.\ninstallStreamTaps();\nlogInvocation(process.argv.slice(2));\ninstallExitRecord();\n\n// `--output json` asks for the envelope, which almost every command prints\n// without declaring the option — translated here so the guard below does not\n// refuse a flag that asked for what the command was about to print.\n// `canvas run` prints progress before its envelope: asked for the envelope, it\n// prints that alone on stdout and the progress on stderr.\nif (asksForEnvelopeAlone(main, process.argv.slice(2))) {\n envelopeAloneOnStdout(process.stdout, process.stderr);\n}\nprocess.argv = [...process.argv.slice(0, 2), ...outputFlagForCommand(main, process.argv.slice(2))];\n\n// `--fields` narrows the envelope on every command that prints one; where the\n// command does not declare it, it is applied to what the command prints.\nconst fieldsFlag = takeFieldsFlag(main, process.argv.slice(2));\nif (fieldsFlag.fields) {\n process.argv = [...process.argv.slice(0, 2), ...fieldsFlag.argv];\n installFieldMask(fieldsFlag.fields, commandPathOf(main, fieldsFlag.argv));\n}\n\n// `--full` on a command with no shorter view asks for what it already prints:\n// taken off here, and said back in the envelope's hints.\nconst fullFlag = takeFullFlag(main, process.argv.slice(2));\nif (fullFlag.taken) {\n process.argv = [...process.argv.slice(0, 2), ...fullFlag.argv];\n installFullNote(commandPathOf(main, fullFlag.argv));\n}\n\n// `--company <id>` names the company a read is about (the organization\n// workspace's Reports read every company of its organization). It travels as a\n// header on every request, so it is taken off here, before the guard.\nconst companyFlag = takeCompanyFlag(main, process.argv.slice(2));\nif (companyFlag.company) {\n process.argv = [...process.argv.slice(0, 2), ...companyFlag.argv];\n setTargetCompany(companyFlag.company);\n}\n\n// What this agent is offered: the organization workspace's agent only reads\n// (`agent-profile.ts`). Here, after `--company` is taken off, so the command it\n// judges is the one typed.\nconst profileRefusal = await applyAgentProfile(main, agentProfile(), process.argv.slice(2));\nif (profileRefusal) {\n writeJson({ ok: false, error: { code: \"FORBIDDEN\", message: profileRefusal } });\n process.exit(1);\n}\n\n// A report's Refresh appends `--no-cache` to every read; a command with no cache\n// already reads fresh, so it is dropped there rather than refused.\nprocess.argv = [...process.argv.slice(0, 2), ...cacheFlagForCommand(main, process.argv.slice(2))];\n\nrefuseUnknownFlags(main, process.argv.slice(2), typedArgv);\nrefuseStrayPositionals(main, process.argv.slice(2));\n\n// Last, so the guard above quotes back the spelling the caller typed: citty\n// resolves a bare `--no-cache` to `cache: false` instead of filling the declared\n// `no-cache` arg, and only the camelCase spelling survives its parser intact.\nprocess.argv = [...process.argv.slice(0, 2), ...cacheFlagForParser(process.argv.slice(2))];\n\n// `--help` and `--version` stay citty's own, the help rendered for an agent\n// reading it (`help-output.ts`). Everything else runs here rather\n// than through `runMain`, whose refusal of a missing argument or an unknown\n// subcommand is usage text on stderr and nothing on stdout: that becomes the\n// envelope every other failure prints.\nconst rawArgs = process.argv.slice(2);\nif (\n rawArgs.some((arg) => arg === \"--help\" || arg === \"-h\") ||\n (rawArgs.length === 1 && /^(--version|-v)$/.test(rawArgs[0] ?? \"\"))\n) {\n runMain(main, { showUsage: printHelpTo(process.stdout) });\n} else {\n try {\n await runCommand(main, { rawArgs });\n } catch (error) {\n const refusal = parseRefusalEnvelope(error, main, rawArgs);\n if (refusal) {\n writeJson(refusal);\n } else {\n console.error(error, \"\\n\");\n }\n process.exit(1);\n }\n}\n","interface ErrorSource {\n on(event: \"error\", listener: (err: NodeJS.ErrnoException) => void): unknown;\n}\n\n/**\n * `baker … | head` closes the pipe once it has its lines. Node reports the next\n * write as an unhandled EPIPE and prints a stack trace, which reads as a crash of\n * a command that did its job. A closed reader wants nothing more, so exit cleanly,\n * as Unix tools do; any other write error still surfaces.\n */\nexport function exitQuietlyOnClosedPipe(stream: ErrorSource, exit: (code: number) => void): void {\n stream.on(\"error\", (err) => {\n if (err.code === \"EPIPE\") {\n exit(0);\n return;\n }\n throw err;\n });\n}\n","/**\n * `--company <id>` on every command: the company the call reads, for the\n * organization workspace, whose Reports read every company of its organization.\n *\n * It is a header, not an argument of each command (`x-baker-company`, sent by\n * `client.ts`), so every read the CLI has works across companies unchanged, and\n * the backend alone decides what it opens: reads of a company of the same\n * organization, for the organization workspace's credential, and nothing else.\n *\n * A command that declares `--company` itself keeps its own meaning — on\n * `avatars research` it is the person's employer. A positional named `company`\n * (`accounts company acme.com`) is not a flag, so the flag stays the header.\n */\n\nimport { declaredArg } from \"./output-flag.ts\";\nimport { commandFor, type IntrospectableCommand } from \"./unknown-flags.ts\";\n\nconst FLAG = \"--company\";\n\n/** The command reads `--company` itself; a positional of that name is no flag, so it is not. */\nfunction ownsCompanyFlag(command: IntrospectableCommand): boolean {\n const own = declaredArg(command, \"company\");\n return own !== null && own.type !== \"positional\";\n}\n\n/**\n * `argv` without `--company`, and the company it named, when the addressed\n * command does not declare the option itself. Otherwise `argv` is returned\n * untouched with `company: null`, for the command or the guard to judge.\n */\nexport function takeCompanyFlag(\n root: IntrospectableCommand,\n argv: string[],\n): { argv: string[]; company: string | null } {\n const end = argv.indexOf(\"--\");\n const limit = end === -1 ? argv.length : end;\n for (let index = 0; index < limit; index++) {\n const token = argv[index] ?? \"\";\n let company: string | undefined;\n let width = 1;\n if (token.startsWith(`${FLAG}=`)) {\n company = token.slice(FLAG.length + 1).trim();\n } else if (token === FLAG) {\n const value = argv[index + 1];\n if (value === undefined || index + 1 >= limit || value.startsWith(\"-\")) {\n return { argv, company: null };\n }\n company = value.trim();\n width = 2;\n } else {\n continue;\n }\n const command = commandFor(root, argv);\n if (!company || !command || ownsCompanyFlag(command)) {\n return { argv, company: null };\n }\n return { argv: [...argv.slice(0, index), ...argv.slice(index + width)], company };\n }\n return { argv, company: null };\n}\n","/**\n * `--full` on every command that prints the JSON envelope.\n *\n * The conventions doc tells the agent that reads are compact and `--full` gives\n * the complete record, and the families that have a compact view declare it\n * (`ads meta ads|adsets|campaigns`, `images`, `winning-ads`, …). Everywhere\n * else the unknown-option guard (`unknown-flags.ts`) refused it, although those\n * commands already print everything they return: `ads meta creatives` loops,\n * `actions get`, `posts list` and `tags list` each lost calls and a retry to a\n * flag that asked for what the command was about to print (BAKER-1412, -182).\n *\n * So a command that does not declare `--full` has it taken off the command line\n * here, and every envelope it prints says so in `hints` — a dropped flag the\n * caller cannot see would read as \"this is the full record\" on a list whose\n * rows are summaries. A command that declares `--full` keeps its own meaning;\n * one that prints no envelope is left to the guard, as with `--output json`.\n */\n\nimport { declaredArg, printsDataEnvelope } from \"./output-flag.ts\";\nimport { parsePrintedEnvelope, reprint, rewriteWrites, withHint } from \"./printed-envelope.ts\";\nimport { commandFor, commandPathOf, type IntrospectableCommand } from \"./unknown-flags.ts\";\n\nconst FLAG = \"--full\";\n\n/**\n * The command a call to `command` runs: a group with a `default` hands the call,\n * flags and all, to that subcommand (`creatives rules` runs `list`).\n */\nfunction commandThatRuns(command: IntrospectableCommand): IntrospectableCommand {\n const name = (command as { default?: unknown }).default;\n const subCommands = command.subCommands;\n const next =\n typeof name === \"string\" && subCommands && typeof subCommands === \"object\"\n ? (subCommands as Record<string, unknown>)[name]\n : undefined;\n return next && typeof next === \"object\" ? commandThatRuns(next as IntrospectableCommand) : command;\n}\n\n/**\n * `argv` without `--full`, and whether it was there, when the addressed command\n * prints the envelope and does not declare the option itself. Otherwise `argv`\n * is returned untouched, for the command or the guard to judge.\n */\nexport function takeFullFlag(root: IntrospectableCommand, argv: string[]): { argv: string[]; taken: boolean } {\n const end = argv.indexOf(\"--\");\n const limit = end === -1 ? argv.length : end;\n const taken = argv.flatMap((token, index) => (index < limit && token === FLAG ? [index] : []));\n if (taken.length === 0) {\n return { argv, taken: false };\n }\n const command = commandFor(root, argv);\n if (!command || declaredArg(commandThatRuns(command), \"full\") || !printsDataEnvelope(commandPathOf(root, argv))) {\n return { argv, taken: false };\n }\n return { argv: argv.filter((_, index) => !taken.includes(index)), taken: true };\n}\n\nfunction fullHint(commandPath: string): string {\n return (\n `--full changes nothing on \\`baker ${commandPath}\\`: it has no shorter view, so this is everything it returns. ` +\n \"Where its rows are summaries, read one record whole with the family's get or show command. Drop --full here.\"\n );\n}\n\n/**\n * The text a command printed, with a success envelope's `hints` saying `--full`\n * was taken and changed nothing; an error or a dry run comes back as printed,\n * and anything that is not an envelope (a readable view) is null.\n */\nexport function noteFullOnPrinted(text: string, commandPath: string): string | null {\n const envelope = parsePrintedEnvelope(text);\n if (envelope === null) {\n return null;\n }\n if (envelope.ok !== true || \"dryRun\" in envelope) {\n return text;\n }\n return reprint(text, withHint(envelope, fullHint(commandPath)));\n}\n\n/**\n * The note on the CLI's own stdout, and on stderr when the command printed no\n * envelope to carry it — a readable view such as `tags list` without `--json`.\n */\nexport function installFullNote(commandPath: string): void {\n const note = rewriteWrites(process.stdout, (text) => noteFullOnPrinted(text, commandPath));\n process.on(\"exit\", () => {\n if (!note.sawEnvelope()) {\n process.stderr.write(`${fullHint(commandPath)}\\n`);\n }\n });\n}\n","/**\n * What `--help` prints, for an agent that reads every byte of it.\n *\n * citty's renderer pads each table column to its widest cell, so one\n * paragraph-long description pads every other row of its table with thousands\n * of spaces (`baker analytics --help` printed 163 KB, 80% of it padding). And it\n * lists each subcommand with its whole description, so a family's help repeats\n * every command's own help. Here a COMMANDS row carries the first sentence (the\n * rest is one `--help` away), and no line ends in padding.\n */\n\nimport { type ArgsDef, type CommandDef, type CommandMeta, type Resolvable, renderUsage } from \"citty\";\n\nconst sentences = new Intl.Segmenter(\"en\", { granularity: \"sentence\" });\n/** ICU's sentence rules end a sentence at these; none of them ends one here. */\nconst abbreviation = /\\b(?:e\\.g|i\\.e|vs|etc)\\.$/i;\n\nfunction resolved<T>(value: Resolvable<T>): Promise<T> {\n return Promise.resolve(typeof value === \"function\" ? (value as () => T | Promise<T>)() : value);\n}\n\n/**\n * The description's first sentence. A line wrapped by hand continues on the\n * next one; a blank line, an indented example or a list item ends the prose.\n */\nfunction firstSentence(description: string): string {\n const [first = \"\", ...rest] = description.trim().split(\"\\n\");\n let prose = first.trim();\n for (const line of rest) {\n if (/[.:!?]$/.test(prose) || line.trim() === \"\" || /^(\\s|[-*•])/.test(line)) break;\n prose += ` ${line.trim()}`;\n }\n let sentence = \"\";\n for (const { segment } of sentences.segment(prose)) {\n sentence += segment;\n if (!abbreviation.test(sentence.trim())) break;\n }\n return (sentence || prose).trim();\n}\n\nasync function summarized(cmd: CommandDef<ArgsDef>): Promise<CommandDef<ArgsDef>> {\n if (!cmd.subCommands) return cmd;\n const subCommands = await resolved(cmd.subCommands);\n const listed: Record<string, CommandDef<ArgsDef>> = {};\n for (const [name, sub] of Object.entries(subCommands)) {\n const command: CommandDef<ArgsDef> = await resolved(sub);\n const meta: CommandMeta = (command.meta ? await resolved(command.meta) : undefined) ?? {};\n listed[name] = { meta: meta.description ? { ...meta, description: firstSentence(meta.description) } : meta };\n }\n return { ...cmd, subCommands: listed };\n}\n\nexport async function renderHelp<T extends ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<string> {\n const usage = await renderUsage(await summarized(cmd as CommandDef<ArgsDef>), parent as CommandDef<ArgsDef>);\n return usage\n .split(\"\\n\")\n .map((line) => line.trimEnd())\n .join(\"\\n\");\n}\n\ntype HelpSink = { write(chunk: string, done: () => void): unknown };\n\n/**\n * citty's `runMain` exits as soon as the help is printed. Piped, stdout writes\n * asynchronously, so an exit then cut the help at whatever had been flushed\n * (`baker --help | wc -c` read 65,536). This resolves once the write is done.\n */\nexport function printHelpTo(stdout: HelpSink) {\n return async <T extends ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<void> => {\n const help = await renderHelp(cmd, parent);\n await new Promise<void>((done) => stdout.write(`${help}\\n`, done));\n };\n}\n","import { defineCommand } from \"citty\";\nimport { getCliVersion } from \"./version.ts\";\n\n// Every command is declared lazily and only the one being run is loaded\n// (`command-loading.ts`): loading all of them made each `baker` process hold\n// ~135 MB of heap while it waited on one request.\nexport const rootCommand = defineCommand({\n meta: {\n name: \"baker\",\n version: getCliVersion(),\n description: `AI-agent CLI for finding and managing images, videos, social posts, avatars, testimonials, action items, scheduled agents, marketing tags, Tag Manager containers, account history, credentials, and ad platform data in Baker.\n\nAuth: Set BAKER_API_KEY (starts with bk_) and BAKER_API_URL environment variables.\nChat: Set BAKER_CHAT_ID for action and scheduled-agent commands that stage changes against a chat.\nOutput: All commands return JSON envelopes: { ok: true, data: ... } or { ok: false, error: { code, message } }.\nFields: --fields a,b,c keeps only those keys of each record in data, on every command that prints the envelope.\nFull: --full returns the complete record where a command has a compact view; elsewhere it is accepted and changes nothing (a hint says so), except on 'canvas run' and 'canvas rerun', which refuse it.\nCompany: --company <id> runs a read against another company of the organization (organization workspace only; ids from 'baker organization companies').\nFormats: --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.)\nIntrospection: Run 'baker schema <command>' to inspect argument schemas.`,\n },\n subCommands: {\n capabilities: () => import(\"./commands/capabilities/index.ts\").then((m) => m.capabilitiesCommand),\n actions: () => import(\"./commands/actions/index.ts\").then((m) => m.actionsCommand),\n \"scheduled-agents\": () => import(\"./commands/scheduled-agents/index.ts\").then((m) => m.scheduledAgentsCommand),\n ads: () => import(\"./commands/ads/index.ts\").then((m) => m.adsCommand),\n brand: () => import(\"./commands/brand/index.ts\").then((m) => m.brandCommand),\n analytics: () => import(\"./commands/analytics/index.ts\").then((m) => m.analyticsCommand),\n experiment: () => import(\"./commands/experiment/index.ts\").then((m) => m.experimentCommand),\n ga4: () => import(\"./commands/ga4/index.ts\").then((m) => m.ga4Command),\n gsc: () => import(\"./commands/gsc/index.ts\").then((m) => m.gscCommand),\n research: () => import(\"./commands/research/index.ts\").then((m) => m.researchCommand),\n decide: () => import(\"./commands/decide/index.ts\").then((m) => m.decideCommand),\n creatives: () => import(\"./commands/creatives/index.ts\").then((m) => m.creativesCommand),\n flows: () => import(\"./commands/flows/index.ts\").then((m) => m.flowsCommand),\n funnel: () => import(\"./commands/funnel/index.ts\").then((m) => m.funnelCommand),\n images: () => import(\"./commands/images/index.ts\").then((m) => m.imagesCommand),\n studio: () => import(\"./commands/studio/index.ts\").then((m) => m.studioCommand),\n avatars: () => import(\"./commands/avatars/index.ts\").then((m) => m.avatarsCommand),\n landing: () => import(\"./commands/landing/index.ts\").then((m) => m.landingCommand),\n videos: () => import(\"./commands/videos/index.ts\").then((m) => m.videosCommand),\n testimonials: () => import(\"./commands/testimonials/index.ts\").then((m) => m.testimonialsCommand),\n canvas: () => import(\"./commands/canvas/index.ts\").then((m) => m.canvasCommand),\n tags: () => import(\"./commands/tags/index.ts\").then((m) => m.tagsCommand),\n \"tag-manager\": () => import(\"./commands/tag-manager/index.ts\").then((m) => m.tagManagerCommand),\n chats: () => import(\"./commands/chats/index.ts\").then((m) => m.chatsCommand),\n history: () => import(\"./commands/history/index.ts\").then((m) => m.historyCommand),\n credentials: () => import(\"./commands/credentials/index.ts\").then((m) => m.credentialsCommand),\n hubspot: () => import(\"./commands/hubspot/index.ts\").then((m) => m.hubspotCommand),\n activecampaign: () => import(\"./commands/activecampaign/index.ts\").then((m) => m.activecampaignCommand),\n accounts: () => import(\"./commands/accounts/index.ts\").then((m) => m.accountsCommand),\n shopify: () => import(\"./commands/shopify/index.ts\").then((m) => m.shopifyCommand),\n \"winning-ads\": () => import(\"./commands/winning-ads/index.ts\").then((m) => m.winningAdsCommand),\n \"media-sources\": () => import(\"./commands/media-sources/index.ts\").then((m) => m.mediaSourcesCommand),\n posts: () => import(\"./commands/posts/index.ts\").then((m) => m.postsCommand),\n site: () => import(\"./commands/site/index.ts\").then((m) => m.siteCommand),\n \"lead-routes\": () => import(\"./commands/lead-routes/index.ts\").then((m) => m.leadRoutesCommand),\n mcp: () => import(\"./commands/mcp/index.ts\").then((m) => m.mcpCommand),\n \"setup-links\": () => import(\"./commands/setup-links/index.ts\").then((m) => m.setupLinksCommand),\n organization: () => import(\"./commands/organization/index.ts\").then((m) => m.organizationCommand),\n schema: () => import(\"./commands/schema.ts\").then((m) => m.schemaCommand),\n },\n});\n","import { readFileSync } from \"node:fs\";\n\nfunction packageJsonUrl(): URL {\n return new URL(\"../package.json\", import.meta.url);\n}\n\nfunction parsePackageVersion(raw: string): string {\n const parsed: unknown = JSON.parse(raw);\n if (\n typeof parsed === \"object\" &&\n parsed !== null &&\n \"version\" in parsed &&\n typeof parsed.version === \"string\" &&\n parsed.version.length > 0\n ) {\n return parsed.version;\n }\n throw new Error(\"Invalid CLI package.json: missing version\");\n}\n\nexport function getCliVersion(): string {\n return parsePackageVersion(readFileSync(packageJsonUrl(), \"utf8\"));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,YAAY,eAAe;;;ACS7B,SAAS,wBAAwB,QAAqB,MAAoC;AAC/F,SAAO,GAAG,SAAS,CAAC,QAAQ;AAC1B,QAAI,IAAI,SAAS,SAAS;AACxB,WAAK,CAAC;AACN;AAAA,IACF;AACA,UAAM;AAAA,EACR,CAAC;AACH;;;ACDA,IAAM,OAAO;AAGb,SAAS,gBAAgB,SAAyC;AAChE,QAAM,MAAM,YAAY,SAAS,SAAS;AAC1C,SAAO,QAAQ,QAAQ,IAAI,SAAS;AACtC;AAOO,SAAS,gBACd,MACA,MAC4C;AAC5C,QAAM,MAAM,KAAK,QAAQ,IAAI;AAC7B,QAAM,QAAQ,QAAQ,KAAK,KAAK,SAAS;AACzC,WAAS,QAAQ,GAAG,QAAQ,OAAO,SAAS;AAC1C,UAAM,QAAQ,KAAK,KAAK,KAAK;AAC7B,QAAI;AACJ,QAAI,QAAQ;AACZ,QAAI,MAAM,WAAW,GAAG,IAAI,GAAG,GAAG;AAChC,gBAAU,MAAM,MAAM,KAAK,SAAS,CAAC,EAAE,KAAK;AAAA,IAC9C,WAAW,UAAU,MAAM;AACzB,YAAM,QAAQ,KAAK,QAAQ,CAAC;AAC5B,U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AK,CAAC;AAChB;AAIA,QAAQ,OAAO,CAAC,GAAG,QAAQ,KAAK,MAAM,GAAG,CAAC,GAAG,GAAG,oBAAoB,MAAM,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC;AAEhG,mBAAmB,MAAM,QAAQ,KAAK,MAAM,CAAC,GAAG,SAAS;AACzD,uBAAuB,MAAM,QAAQ,KAAK,MAAM,CAAC,CAAC;AAKlD,QAAQ,OAAO,CAAC,GAAG,QAAQ,KAAK,MAAM,GAAG,CAAC,GAAG,GAAG,mBAAmB,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC;AAOzF,IAAM,UAAU,QAAQ,KAAK,MAAM,CAAC;AACpC,IACE,QAAQ,KAAK,CAAC,QAAQ,QAAQ,YAAY,QAAQ,IAAI,KACrD,QAAQ,WAAW,KAAK,mBAAmB,KAAK,QAAQ,CAAC,KAAK,EAAE,GACjE;AACA,UAAQ,MAAM,EAAE,WAAW,YAAY,QAAQ,MAAM,EAAE,CAAC;AAC1D,OAAO;AACL,MAAI;AACF,UAAM,WAAW,MAAM,EAAE,QAAQ,CAAC;AAAA,EACpC,SAAS,OAAO;AACd,UAAM,UAAU,qBAAqB,OAAO,MAAM,OAAO;AACzD,QAAI,SAAS;AACX,gBAAU,OAAO;AAAA,IACnB,OAAO;AACL,cAAQ,MAAM,OAAO,IAAI;AAAA,IAC3B;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":["FLAG"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/closed-pipe.ts","../src/company-flag.ts","../src/full-flag.ts","../src/help-output.ts","../src/root-command.ts","../src/version.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { runCommand, runMain } from \"citty\";\nimport { agentProfile, applyAgentProfile } from \"./agent-profile.ts\";\nimport { cacheFlagForCommand, cacheFlagForParser, normalizeCacheFlag } from \"./cache-flag.ts\";\nimport { exitQuietlyOnClosedPipe } from \"./closed-pipe.ts\";\nimport { loadCommands } from \"./command-loading.ts\";\nimport { takeCompanyFlag } from \"./company-flag.ts\";\nimport { installExitRecord, installStreamTaps, logInvocation } from \"./debugLog.ts\";\nimport { setTargetCompany } from \"./env.ts\";\nimport { installFieldMask, takeFieldsFlag } from \"./field-mask.ts\";\nimport { installFullNote, takeFullFlag } from \"./full-flag.ts\";\nimport { printHelpTo } from \"./help-output.ts\";\nimport { writeJson } from \"./output.ts\";\nimport { asksForEnvelopeAlone, envelopeAloneOnStdout, outputFlagForCommand } from \"./output-flag.ts\";\nimport { rootCommand } from \"./root-command.ts\";\nimport { registerCommandTree } from \"./schemas.ts\";\nimport { commandPathOf, parseRefusalEnvelope, refuseStrayPositionals, refuseUnknownFlags } from \"./unknown-flags.ts\";\n\nconst main = rootCommand;\n// The call as typed, before the rewrites below: a refusal's corrected call is built from it.\nconst typedArgv = process.argv.slice(2);\n\nawait loadCommands(main, process.argv.slice(2));\nregisterCommandTree(main);\n\nexitQuietlyOnClosedPipe(process.stdout, (code) => process.exit(code));\n\n// The legacy `--skip-cache` spelling becomes `--no-cache` before anything reads\n// argv — citty parses `process.argv` itself, so the rewrite has to land there.\nprocess.argv = [...process.argv.slice(0, 2), ...normalizeCacheFlag(process.argv.slice(2))];\n\n// When BAKER_DEBUG_LOG is set, mirror all output and record the invocation\n// before any command runs. No-op otherwise.\ninstallStreamTaps();\nlogInvocation(process.argv.slice(2));\ninstallExitRecord();\n\n// `--output json` asks for the envelope, which almost every command prints\n// without declaring the option — translated here so the guard below does not\n// refuse a flag that asked for what the command was about to print.\n// `canvas run` prints progress before its envelope: asked for the envelope, it\n// prints that alone on stdout and the progress on stderr.\nif (asksForEnvelopeAlone(main, process.argv.slice(2))) {\n envelopeAloneOnStdout(process.stdout, process.stderr);\n}\nprocess.argv = [...process.argv.slice(0, 2), ...outputFlagForCommand(main, process.argv.slice(2))];\n\n// `--fields` narrows the envelope on every command that prints one; where the\n// command does not declare it, it is applied to what the command prints.\nconst fieldsFlag = takeFieldsFlag(main, process.argv.slice(2));\nif (fieldsFlag.fields) {\n process.argv = [...process.argv.slice(0, 2), ...fieldsFlag.argv];\n installFieldMask(fieldsFlag.fields, commandPathOf(main, fieldsFlag.argv));\n}\n\n// `--full` on a command with no shorter view asks for what it already prints:\n// taken off here, and said back in the envelope's hints.\nconst fullFlag = takeFullFlag(main, process.argv.slice(2));\nif (fullFlag.taken) {\n process.argv = [...process.argv.slice(0, 2), ...fullFlag.argv];\n installFullNote(commandPathOf(main, fullFlag.argv));\n}\n\n// `--company <id>` names the company a read is about (the organization\n// workspace's Reports read every company of its organization). It travels as a\n// header on every request, so it is taken off here, before the guard.\nconst companyFlag = takeCompanyFlag(main, process.argv.slice(2));\nif (companyFlag.company) {\n process.argv = [...process.argv.slice(0, 2), ...companyFlag.argv];\n setTargetCompany(companyFlag.company);\n}\n\n// What this agent is offered: the organization workspace's agent only reads\n// (`agent-profile.ts`). Here, after `--company` is taken off, so the command it\n// judges is the one typed.\nconst profileRefusal = await applyAgentProfile(main, agentProfile(), process.argv.slice(2));\nif (profileRefusal) {\n writeJson({ ok: false, error: { code: \"FORBIDDEN\", message: profileRefusal } });\n process.exit(1);\n}\n\n// A report's Refresh appends `--no-cache` to every read; a command with no cache\n// already reads fresh, so it is dropped there rather than refused.\nprocess.argv = [...process.argv.slice(0, 2), ...cacheFlagForCommand(main, process.argv.slice(2))];\n\nrefuseUnknownFlags(main, process.argv.slice(2), typedArgv);\nrefuseStrayPositionals(main, process.argv.slice(2));\n\n// Last, so the guard above quotes back the spelling the caller typed: citty\n// resolves a bare `--no-cache` to `cache: false` instead of filling the declared\n// `no-cache` arg, and only the camelCase spelling survives its parser intact.\nprocess.argv = [...process.argv.slice(0, 2), ...cacheFlagForParser(process.argv.slice(2))];\n\n// `--help` and `--version` stay citty's own, the help rendered for an agent\n// reading it (`help-output.ts`). Everything else runs here rather\n// than through `runMain`, whose refusal of a missing argument or an unknown\n// subcommand is usage text on stderr and nothing on stdout: that becomes the\n// envelope every other failure prints.\nconst rawArgs = process.argv.slice(2);\nif (\n rawArgs.some((arg) => arg === \"--help\" || arg === \"-h\") ||\n (rawArgs.length === 1 && /^(--version|-v)$/.test(rawArgs[0] ?? \"\"))\n) {\n runMain(main, { showUsage: printHelpTo(process.stdout) });\n} else {\n try {\n await runCommand(main, { rawArgs });\n } catch (error) {\n const refusal = parseRefusalEnvelope(error, main, rawArgs);\n if (refusal) {\n writeJson(refusal);\n } else {\n console.error(error, \"\\n\");\n }\n process.exit(1);\n }\n}\n","interface ErrorSource {\n on(event: \"error\", listener: (err: NodeJS.ErrnoException) => void): unknown;\n}\n\n/**\n * `baker … | head` closes the pipe once it has its lines. Node reports the next\n * write as an unhandled EPIPE and prints a stack trace, which reads as a crash of\n * a command that did its job. A closed reader wants nothing more, so exit cleanly,\n * as Unix tools do; any other write error still surfaces.\n */\nexport function exitQuietlyOnClosedPipe(stream: ErrorSource, exit: (code: number) => void): void {\n stream.on(\"error\", (err) => {\n if (err.code === \"EPIPE\") {\n exit(0);\n return;\n }\n throw err;\n });\n}\n","/**\n * `--company <id>` on every command: the company the call reads, for the\n * organization workspace, whose Reports read every company of its organization.\n *\n * It is a header, not an argument of each command (`x-baker-company`, sent by\n * `client.ts`), so every read the CLI has works across companies unchanged, and\n * the backend alone decides what it opens: reads of a company of the same\n * organization, for the organization workspace's credential, and nothing else.\n *\n * A command that declares `--company` itself keeps its own meaning — on\n * `avatars research` it is the person's employer. A positional named `company`\n * (`accounts company acme.com`) is not a flag, so the flag stays the header.\n */\n\nimport { declaredArg } from \"./output-flag.ts\";\nimport { commandFor, type IntrospectableCommand } from \"./unknown-flags.ts\";\n\nconst FLAG = \"--company\";\n\n/** The command reads `--company` itself; a positional of that name is no flag, so it is not. */\nfunction ownsCompanyFlag(command: IntrospectableCommand): boolean {\n const own = declaredArg(command, \"company\");\n return own !== null && own.type !== \"positional\";\n}\n\n/**\n * `argv` without `--company`, and the company it named, when the addressed\n * command does not declare the option itself. Otherwise `argv` is returned\n * untouched with `company: null`, for the command or the guard to judge.\n */\nexport function takeCompanyFlag(\n root: IntrospectableCommand,\n argv: string[],\n): { argv: string[]; company: string | null } {\n const end = argv.indexOf(\"--\");\n const limit = end === -1 ? argv.length : end;\n for (let index = 0; index < limit; index++) {\n const token = argv[index] ?? \"\";\n let company: string | undefined;\n let width = 1;\n if (token.startsWith(`${FLAG}=`)) {\n company = token.slice(FLAG.length + 1).trim();\n } else if (token === FLAG) {\n const value = argv[index + 1];\n if (value === undefined || index + 1 >= limit || value.startsWith(\"-\")) {\n return { argv, company: null };\n }\n company = value.trim();\n width = 2;\n } else {\n continue;\n }\n const command = commandFor(root, argv);\n if (!company || !command || ownsCompanyFlag(command)) {\n return { argv, company: null };\n }\n return { argv: [...argv.slice(0, index), ...argv.slice(index + width)], company };\n }\n return { argv, company: null };\n}\n","/**\n * `--full` on every command that prints the JSON envelope.\n *\n * The conventions doc tells the agent that reads are compact and `--full` gives\n * the complete record, and the families that have a compact view declare it\n * (`ads meta ads|adsets|campaigns`, `images`, `winning-ads`, …). Everywhere\n * else the unknown-option guard (`unknown-flags.ts`) refused it, although those\n * commands already print everything they return: `ads meta creatives` loops,\n * `actions get`, `posts list` and `tags list` each lost calls and a retry to a\n * flag that asked for what the command was about to print (BAKER-1412, -182).\n *\n * So a command that does not declare `--full` has it taken off the command line\n * here, and every envelope it prints says so in `hints` — a dropped flag the\n * caller cannot see would read as \"this is the full record\" on a list whose\n * rows are summaries. A command that declares `--full` keeps its own meaning;\n * one that prints no envelope is left to the guard, as with `--output json`.\n */\n\nimport { declaredArg, printsDataEnvelope } from \"./output-flag.ts\";\nimport { parsePrintedEnvelope, reprint, rewriteWrites, withHint } from \"./printed-envelope.ts\";\nimport { commandFor, commandPathOf, type IntrospectableCommand } from \"./unknown-flags.ts\";\n\nconst FLAG = \"--full\";\n\n/**\n * The command a call to `command` runs: a group with a `default` hands the call,\n * flags and all, to that subcommand (`creatives rules` runs `list`).\n */\nfunction commandThatRuns(command: IntrospectableCommand): IntrospectableCommand {\n const name = (command as { default?: unknown }).default;\n const subCommands = command.subCommands;\n const next =\n typeof name === \"string\" && subCommands && typeof subCommands === \"object\"\n ? (subCommands as Record<string, unknown>)[name]\n : undefined;\n return next && typeof next === \"object\" ? commandThatRuns(next as IntrospectableCommand) : command;\n}\n\n/**\n * `argv` without `--full`, and whether it was there, when the addressed command\n * prints the envelope and does not declare the option itself. Otherwise `argv`\n * is returned untouched, for the command or the guard to judge.\n */\nexport function takeFullFlag(root: IntrospectableCommand, argv: string[]): { argv: string[]; taken: boolean } {\n const end = argv.indexOf(\"--\");\n const limit = end === -1 ? argv.length : end;\n const taken = argv.flatMap((token, index) => (index < limit && token === FLAG ? [index] : []));\n if (taken.length === 0) {\n return { argv, taken: false };\n }\n const command = commandFor(root, argv);\n if (!command || declaredArg(commandThatRuns(command), \"full\") || !printsDataEnvelope(commandPathOf(root, argv))) {\n return { argv, taken: false };\n }\n return { argv: argv.filter((_, index) => !taken.includes(index)), taken: true };\n}\n\nfunction fullHint(commandPath: string): string {\n return (\n `--full changes nothing on \\`baker ${commandPath}\\`: it has no shorter view, so this is everything it returns. ` +\n \"Where its rows are summaries, read one record whole with the family's get or show command. Drop --full here.\"\n );\n}\n\n/**\n * The text a command printed, with a success envelope's `hints` saying `--full`\n * was taken and changed nothing; an error or a dry run comes back as printed,\n * and anything that is not an envelope (a readable view) is null.\n */\nexport function noteFullOnPrinted(text: string, commandPath: string): string | null {\n const envelope = parsePrintedEnvelope(text);\n if (envelope === null) {\n return null;\n }\n if (envelope.ok !== true || \"dryRun\" in envelope) {\n return text;\n }\n return reprint(text, withHint(envelope, fullHint(commandPath)));\n}\n\n/**\n * The note on the CLI's own stdout, and on stderr when the command printed no\n * envelope to carry it — a readable view such as `tags list` without `--json`.\n */\nexport function installFullNote(commandPath: string): void {\n const note = rewriteWrites(process.stdout, (text) => noteFullOnPrinted(text, commandPath));\n process.on(\"exit\", () => {\n if (!note.sawEnvelope()) {\n process.stderr.write(`${fullHint(commandPath)}\\n`);\n }\n });\n}\n","/**\n * What `--help` prints, for an agent that reads every byte of it.\n *\n * citty's renderer pads each table column to its widest cell, so one\n * paragraph-long description pads every other row of its table with thousands\n * of spaces (`baker analytics --help` printed 163 KB, 80% of it padding). And it\n * lists each subcommand with its whole description, so a family's help repeats\n * every command's own help. Here a COMMANDS row carries the first sentence (the\n * rest is one `--help` away), and no line ends in padding.\n */\n\nimport { type ArgsDef, type CommandDef, type CommandMeta, type Resolvable, renderUsage } from \"citty\";\n\nconst sentences = new Intl.Segmenter(\"en\", { granularity: \"sentence\" });\n/** ICU's sentence rules end a sentence at these; none of them ends one here. */\nconst abbreviation = /\\b(?:e\\.g|i\\.e|vs|etc)\\.$/i;\n\nfunction resolved<T>(value: Resolvable<T>): Promise<T> {\n return Promise.resolve(typeof value === \"function\" ? (value as () => T | Promise<T>)() : value);\n}\n\n/**\n * The description's first sentence. A line wrapped by hand continues on the\n * next one; a blank line, an indented example or a list item ends the prose.\n */\nfunction firstSentence(description: string): string {\n const [first = \"\", ...rest] = description.trim().split(\"\\n\");\n let prose = first.trim();\n for (const line of rest) {\n if (/[.:!?]$/.test(prose) || line.trim() === \"\" || /^(\\s|[-*•])/.test(line)) break;\n prose += ` ${line.trim()}`;\n }\n let sentence = \"\";\n for (const { segment } of sentences.segment(prose)) {\n sentence += segment;\n if (!abbreviation.test(sentence.trim())) break;\n }\n return (sentence || prose).trim();\n}\n\nasync function summarized(cmd: CommandDef<ArgsDef>): Promise<CommandDef<ArgsDef>> {\n if (!cmd.subCommands) return cmd;\n const subCommands = await resolved(cmd.subCommands);\n const listed: Record<string, CommandDef<ArgsDef>> = {};\n for (const [name, sub] of Object.entries(subCommands)) {\n const command: CommandDef<ArgsDef> = await resolved(sub);\n const meta: CommandMeta = (command.meta ? await resolved(command.meta) : undefined) ?? {};\n listed[name] = { meta: meta.description ? { ...meta, description: firstSentence(meta.description) } : meta };\n }\n return { ...cmd, subCommands: listed };\n}\n\nexport async function renderHelp<T extends ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<string> {\n const usage = await renderUsage(await summarized(cmd as CommandDef<ArgsDef>), parent as CommandDef<ArgsDef>);\n return usage\n .split(\"\\n\")\n .map((line) => line.trimEnd())\n .join(\"\\n\");\n}\n\ntype HelpSink = { write(chunk: string, done: () => void): unknown };\n\n/**\n * citty's `runMain` exits as soon as the help is printed. Piped, stdout writes\n * asynchronously, so an exit then cut the help at whatever had been flushed\n * (`baker --help | wc -c` read 65,536). This resolves once the write is done.\n */\nexport function printHelpTo(stdout: HelpSink) {\n return async <T extends ArgsDef>(cmd: CommandDef<T>, parent?: CommandDef<T>): Promise<void> => {\n const help = await renderHelp(cmd, parent);\n await new Promise<void>((done) => stdout.write(`${help}\\n`, done));\n };\n}\n","import { defineCommand } from \"citty\";\nimport { getCliVersion } from \"./version.ts\";\n\n// Every command is declared lazily and only the one being run is loaded\n// (`command-loading.ts`): loading all of them made each `baker` process hold\n// ~135 MB of heap while it waited on one request.\nexport const rootCommand = defineCommand({\n meta: {\n name: \"baker\",\n version: getCliVersion(),\n description: `AI-agent CLI for finding and managing images, videos, social posts, avatars, testimonials, action items, scheduled agents, marketing tags, Tag Manager containers, account history, credentials, and ad platform data in Baker.\n\nAuth: Set BAKER_API_KEY (starts with bk_) and BAKER_API_URL environment variables.\nChat: Set BAKER_CHAT_ID for action and scheduled-agent commands that stage changes against a chat.\nOutput: All commands return JSON envelopes: { ok: true, data: ... } or { ok: false, error: { code, message } }.\nFields: --fields a,b,c keeps only those keys of each record in data, on every command that prints the envelope.\nFull: --full returns the complete record where a command has a compact view; elsewhere it is accepted and changes nothing (a hint says so), except on 'canvas run' and 'canvas rerun', which refuse it.\nCompany: --company <id> runs a read against another company of the organization (organization workspace only; ids from 'baker organization companies').\nFormats: --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.)\nIntrospection: Run 'baker schema <command>' to inspect argument schemas.`,\n },\n subCommands: {\n capabilities: () => import(\"./commands/capabilities/index.ts\").then((m) => m.capabilitiesCommand),\n actions: () => import(\"./commands/actions/index.ts\").then((m) => m.actionsCommand),\n \"scheduled-agents\": () => import(\"./commands/scheduled-agents/index.ts\").then((m) => m.scheduledAgentsCommand),\n ads: () => import(\"./commands/ads/index.ts\").then((m) => m.adsCommand),\n brand: () => import(\"./commands/brand/index.ts\").then((m) => m.brandCommand),\n analytics: () => import(\"./commands/analytics/index.ts\").then((m) => m.analyticsCommand),\n experiment: () => import(\"./commands/experiment/index.ts\").then((m) => m.experimentCommand),\n ga4: () => import(\"./commands/ga4/index.ts\").then((m) => m.ga4Command),\n gsc: () => import(\"./commands/gsc/index.ts\").then((m) => m.gscCommand),\n research: () => import(\"./commands/research/index.ts\").then((m) => m.researchCommand),\n decide: () => import(\"./commands/decide/index.ts\").then((m) => m.decideCommand),\n knowledge: () => import(\"./commands/knowledge/index.ts\").then((m) => m.knowledgeCommand),\n creatives: () => import(\"./commands/creatives/index.ts\").then((m) => m.creativesCommand),\n flows: () => import(\"./commands/flows/index.ts\").then((m) => m.flowsCommand),\n funnel: () => import(\"./commands/funnel/index.ts\").then((m) => m.funnelCommand),\n images: () => import(\"./commands/images/index.ts\").then((m) => m.imagesCommand),\n studio: () => import(\"./commands/studio/index.ts\").then((m) => m.studioCommand),\n avatars: () => import(\"./commands/avatars/index.ts\").then((m) => m.avatarsCommand),\n landing: () => import(\"./commands/landing/index.ts\").then((m) => m.landingCommand),\n videos: () => import(\"./commands/videos/index.ts\").then((m) => m.videosCommand),\n testimonials: () => import(\"./commands/testimonials/index.ts\").then((m) => m.testimonialsCommand),\n canvas: () => import(\"./commands/canvas/index.ts\").then((m) => m.canvasCommand),\n tags: () => import(\"./commands/tags/index.ts\").then((m) => m.tagsCommand),\n \"tag-manager\": () => import(\"./commands/tag-manager/index.ts\").then((m) => m.tagManagerCommand),\n chats: () => import(\"./commands/chats/index.ts\").then((m) => m.chatsCommand),\n history: () => import(\"./commands/history/index.ts\").then((m) => m.historyCommand),\n credentials: () => import(\"./commands/credentials/index.ts\").then((m) => m.credentialsCommand),\n hubspot: () => import(\"./commands/hubspot/index.ts\").then((m) => m.hubspotCommand),\n activecampaign: () => import(\"./commands/activecampaign/index.ts\").then((m) => m.activecampaignCommand),\n accounts: () => import(\"./commands/accounts/index.ts\").then((m) => m.accountsCommand),\n shopify: () => import(\"./commands/shopify/index.ts\").then((m) => m.shopifyCommand),\n \"winning-ads\": () => import(\"./commands/winning-ads/index.ts\").then((m) => m.winningAdsCommand),\n \"media-sources\": () => import(\"./commands/media-sources/index.ts\").then((m) => m.mediaSourcesCommand),\n posts: () => import(\"./commands/posts/index.ts\").then((m) => m.postsCommand),\n site: () => import(\"./commands/site/index.ts\").then((m) => m.siteCommand),\n \"lead-routes\": () => import(\"./commands/lead-routes/index.ts\").then((m) => m.leadRoutesCommand),\n mcp: () => import(\"./commands/mcp/index.ts\").then((m) => m.mcpCommand),\n \"setup-links\": () => import(\"./commands/setup-links/index.ts\").then((m) => m.setupLinksCommand),\n organization: () => import(\"./commands/organization/index.ts\").then((m) => m.organizationCommand),\n schema: () => import(\"./commands/schema.ts\").then((m) => m.schemaCommand),\n },\n});\n","import { readFileSync } from \"node:fs\";\n\nfunction packageJsonUrl(): URL {\n return new URL(\"../package.json\", import.meta.url);\n}\n\nfunction parsePackageVersion(raw: string): string {\n const parsed: unknown = JSON.parse(raw);\n if (\n typeof parsed === \"object\" &&\n parsed !== null &&\n \"version\" in parsed &&\n typeof parsed.version === \"string\" &&\n parsed.version.length > 0\n ) {\n return parsed.version;\n }\n throw new Error(\"Invalid CLI package.json: missing version\");\n}\n\nexport function getCliVersion(): string {\n return parsePackageVersion(readFileSync(packageJsonUrl(), \"utf8\"));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,YAAY,eAAe;;;ACS7B,SAAS,wBAAwB,QAAqB,MAAoC;AAC/F,SAAO,GAAG,SAAS,CAAC,QAAQ;AAC1B,QAAI,IAAI,SAAS,SA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AE,GACjE;AACA,UAAQ,MAAM,EAAE,WAAW,YAAY,QAAQ,MAAM,EAAE,CAAC;AAC1D,OAAO;AACL,MAAI;AACF,UAAM,WAAW,MAAM,EAAE,QAAQ,CAAC;AAAA,EACpC,SAAS,OAAO;AACd,UAAM,UAAU,qBAAqB,OAAO,MAAM,OAAO;AACzD,QAAI,SAAS;AACX,gBAAU,OAAO;AAAA,IACnB,OAAO;AACL,cAAQ,MAAM,OAAO,IAAI;AAAA,IAC3B;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":["FLAG"]}
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
reactionBody,
|
|
14
14
|
refuseAutoPublish,
|
|
15
15
|
slackBody
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-PGBZ73UZ.js";
|
|
17
|
+
import "./chunk-4ULRDQVD.js";
|
|
18
18
|
import "./chunk-HVJJEQDQ.js";
|
|
19
19
|
import "./chunk-QV6AST5T.js";
|
|
20
20
|
import "./chunk-WCU362Z6.js";
|
|
@@ -132,4 +132,4 @@ var createCommand = defineCommand({
|
|
|
132
132
|
export {
|
|
133
133
|
createCommand
|
|
134
134
|
};
|
|
135
|
-
//# sourceMappingURL=create-
|
|
135
|
+
//# sourceMappingURL=create-PYP3QWTL.js.map
|
|
@@ -39,15 +39,15 @@ How published creatives are doing in live Meta ads (results, fatigue, angle; hoo
|
|
|
39
39
|
Full guide: __tooling__/docs/tools/baker/creatives.md`
|
|
40
40
|
},
|
|
41
41
|
subCommands: {
|
|
42
|
-
brief: () => import("./brief-
|
|
42
|
+
brief: () => import("./brief-SLTB3EPO.js").then((m) => m.briefCommand),
|
|
43
43
|
ideas: () => import("./ideas-CVXHFVX7.js").then((m) => m.ideasCommand),
|
|
44
|
-
make: () => import("./make-
|
|
45
|
-
translate: () => import("./translate-
|
|
44
|
+
make: () => import("./make-T6HLXIYY.js").then((m) => m.makeCommand),
|
|
45
|
+
translate: () => import("./translate-II4JY2XW.js").then((m) => m.translateCommand),
|
|
46
46
|
learn: () => import("./learn-QPXZZIZZ.js").then((m) => m.learnCommand),
|
|
47
|
-
feedback: () => import("./feedback-
|
|
47
|
+
feedback: () => import("./feedback-TJRYTOR3.js").then((m) => m.feedbackCommand),
|
|
48
48
|
rules: () => import("./rules-56E55SGC.js").then((m) => m.rulesCommand),
|
|
49
49
|
check: () => import("./check-AQO7CMDD.js").then((m) => m.checkCommand),
|
|
50
|
-
select: () => import("./select-
|
|
50
|
+
select: () => import("./select-FCQUYBKV.js").then((m) => m.selectCommand),
|
|
51
51
|
publish: () => import("./publish-6ZXFUBGP.js").then((m) => m.publishCommand),
|
|
52
52
|
performance: () => import("./performance-NVURSEZ6.js").then((m) => m.performanceCommand)
|
|
53
53
|
}
|
|
@@ -55,4 +55,4 @@ Full guide: __tooling__/docs/tools/baker/creatives.md`
|
|
|
55
55
|
export {
|
|
56
56
|
creativesCommand
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=creatives-
|
|
58
|
+
//# sourceMappingURL=creatives-ANTJUTIE.js.map
|
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
FRAME_PLACEHOLDER_NOTE,
|
|
3
3
|
exitOnPrepareError,
|
|
4
4
|
prepareCanvas
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-ECJIMIEJ.js";
|
|
7
|
-
import "./chunk-4JS2O2KV.js";
|
|
8
|
-
import "./chunk-XPDUBDPL.js";
|
|
5
|
+
} from "./chunk-CSCHS3JG.js";
|
|
9
6
|
import "./chunk-6M77QNJ4.js";
|
|
10
7
|
import "./chunk-EKX37C3T.js";
|
|
11
8
|
import "./chunk-3WSJGYA3.js";
|
|
9
|
+
import "./chunk-ECJIMIEJ.js";
|
|
10
|
+
import "./chunk-4JS2O2KV.js";
|
|
11
|
+
import "./chunk-XPDUBDPL.js";
|
|
12
12
|
import "./chunk-R6T25WTZ.js";
|
|
13
13
|
import "./chunk-JCVPZ7CV.js";
|
|
14
14
|
import "./chunk-CREEY2FS.js";
|
|
@@ -229,4 +229,4 @@ var critiqueCommand = defineCommand({
|
|
|
229
229
|
export {
|
|
230
230
|
critiqueCommand
|
|
231
231
|
};
|
|
232
|
-
//# sourceMappingURL=critique-
|
|
232
|
+
//# sourceMappingURL=critique-MZUTDK4V.js.map
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
failValidation,
|
|
4
4
|
validateScheduledAgentRef,
|
|
5
5
|
writeOk
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-PGBZ73UZ.js";
|
|
7
|
+
import "./chunk-4ULRDQVD.js";
|
|
8
8
|
import "./chunk-HVJJEQDQ.js";
|
|
9
9
|
import "./chunk-QV6AST5T.js";
|
|
10
10
|
import "./chunk-WCU362Z6.js";
|
|
@@ -64,4 +64,4 @@ var deleteCommand = defineCommand({
|
|
|
64
64
|
export {
|
|
65
65
|
deleteCommand
|
|
66
66
|
};
|
|
67
|
-
//# sourceMappingURL=delete-
|
|
67
|
+
//# sourceMappingURL=delete-3H6YH4YK.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readCreativeIdea,
|
|
3
3
|
withAnchor
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-ECJIMIEJ.js";
|
|
8
|
-
import "./chunk-4JS2O2KV.js";
|
|
9
|
-
import "./chunk-XPDUBDPL.js";
|
|
4
|
+
} from "./chunk-EZBZU6N7.js";
|
|
5
|
+
import "./chunk-Y25HSPRJ.js";
|
|
6
|
+
import "./chunk-CSCHS3JG.js";
|
|
10
7
|
import "./chunk-6M77QNJ4.js";
|
|
11
8
|
import "./chunk-EKX37C3T.js";
|
|
12
9
|
import "./chunk-3WSJGYA3.js";
|
|
10
|
+
import "./chunk-ECJIMIEJ.js";
|
|
11
|
+
import "./chunk-4JS2O2KV.js";
|
|
12
|
+
import "./chunk-XPDUBDPL.js";
|
|
13
13
|
import "./chunk-R6T25WTZ.js";
|
|
14
14
|
import "./chunk-JCVPZ7CV.js";
|
|
15
15
|
import "./chunk-CREEY2FS.js";
|
|
@@ -96,7 +96,7 @@ var feedbackCommand = defineCommand({
|
|
|
96
96
|
meta: { name: "feedback", description: DESCRIPTION },
|
|
97
97
|
subCommands: {
|
|
98
98
|
read: feedbackReadCommand,
|
|
99
|
-
record: () => import("./feedback-record-
|
|
99
|
+
record: () => import("./feedback-record-7IAJI5IY.js").then((m) => m.feedbackRecordCommand)
|
|
100
100
|
},
|
|
101
101
|
// `args` stays although the parent has no `run`: citty finds the subcommand
|
|
102
102
|
// name with THIS command's arg defs, so without them `--slug spring-offer`
|
|
@@ -108,4 +108,4 @@ var feedbackCommand = defineCommand({
|
|
|
108
108
|
export {
|
|
109
109
|
feedbackCommand
|
|
110
110
|
};
|
|
111
|
-
//# sourceMappingURL=feedback-
|
|
111
|
+
//# sourceMappingURL=feedback-TJRYTOR3.js.map
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readCreativeIdea,
|
|
3
|
+
withAnchor
|
|
4
|
+
} from "./chunk-EZBZU6N7.js";
|
|
1
5
|
import {
|
|
2
6
|
modelRuleDrafter,
|
|
3
7
|
repeatedReasons,
|
|
@@ -7,19 +11,15 @@ import {
|
|
|
7
11
|
} from "./chunk-XJHUSJY6.js";
|
|
8
12
|
import {
|
|
9
13
|
versionOf
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
withAnchor
|
|
14
|
-
} from "./chunk-7ODQ6ZID.js";
|
|
15
|
-
import "./chunk-WQKBEC4I.js";
|
|
16
|
-
import "./chunk-3N2KAOVM.js";
|
|
17
|
-
import "./chunk-ECJIMIEJ.js";
|
|
18
|
-
import "./chunk-4JS2O2KV.js";
|
|
19
|
-
import "./chunk-XPDUBDPL.js";
|
|
14
|
+
} from "./chunk-XWO6CXNG.js";
|
|
15
|
+
import "./chunk-Y25HSPRJ.js";
|
|
16
|
+
import "./chunk-CSCHS3JG.js";
|
|
20
17
|
import "./chunk-6M77QNJ4.js";
|
|
21
18
|
import "./chunk-EKX37C3T.js";
|
|
22
19
|
import "./chunk-3WSJGYA3.js";
|
|
20
|
+
import "./chunk-ECJIMIEJ.js";
|
|
21
|
+
import "./chunk-4JS2O2KV.js";
|
|
22
|
+
import "./chunk-XPDUBDPL.js";
|
|
23
23
|
import "./chunk-R6T25WTZ.js";
|
|
24
24
|
import {
|
|
25
25
|
frontmatterOf
|
|
@@ -262,4 +262,4 @@ var feedbackRecordCommand = defineCommand({
|
|
|
262
262
|
export {
|
|
263
263
|
feedbackRecordCommand
|
|
264
264
|
};
|
|
265
|
-
//# sourceMappingURL=feedback-record-
|
|
265
|
+
//# sourceMappingURL=feedback-record-7IAJI5IY.js.map
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
failValidation,
|
|
4
4
|
isTempScheduledAgentId,
|
|
5
5
|
validateScheduledAgentRef
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-PGBZ73UZ.js";
|
|
7
|
+
import "./chunk-4ULRDQVD.js";
|
|
8
8
|
import {
|
|
9
9
|
CHAT_READ_ARG
|
|
10
10
|
} from "./chunk-PFBQERWX.js";
|
|
@@ -79,4 +79,4 @@ var getCommand = defineCommand({
|
|
|
79
79
|
export {
|
|
80
80
|
getCommand
|
|
81
81
|
};
|
|
82
|
-
//# sourceMappingURL=get-
|
|
82
|
+
//# sourceMappingURL=get-XPJ4BZGP.js.map
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
failApi,
|
|
3
3
|
failValidation,
|
|
4
4
|
validateScheduledAgentRef
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-PGBZ73UZ.js";
|
|
6
|
+
import "./chunk-4ULRDQVD.js";
|
|
7
7
|
import "./chunk-HVJJEQDQ.js";
|
|
8
8
|
import "./chunk-QV6AST5T.js";
|
|
9
9
|
import "./chunk-WCU362Z6.js";
|
|
@@ -99,4 +99,4 @@ function historyOnly(raw) {
|
|
|
99
99
|
export {
|
|
100
100
|
historyCommand
|
|
101
101
|
};
|
|
102
|
-
//# sourceMappingURL=history-
|
|
102
|
+
//# sourceMappingURL=history-RD2YMNNL.js.map
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import {
|
|
2
|
+
apiPost
|
|
3
|
+
} from "./chunk-B4UVJCJ4.js";
|
|
4
|
+
import "./chunk-AFQF6ISC.js";
|
|
5
|
+
import "./chunk-52IYZCRS.js";
|
|
6
|
+
import {
|
|
7
|
+
registerSchema,
|
|
8
|
+
writeJson
|
|
9
|
+
} from "./chunk-FSGJSREN.js";
|
|
10
|
+
import "./chunk-YQSBHWOI.js";
|
|
11
|
+
|
|
12
|
+
// src/commands/knowledge/index.ts
|
|
13
|
+
import { defineCommand as defineCommand2 } from "citty";
|
|
14
|
+
|
|
15
|
+
// src/commands/knowledge/search.ts
|
|
16
|
+
import { execFile } from "child_process";
|
|
17
|
+
import { promisify } from "util";
|
|
18
|
+
|
|
19
|
+
// ../api/src/knowledge.ts
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
var KNOWLEDGE_RANK_MAX_PASSAGES = 40;
|
|
22
|
+
var KNOWLEDGE_RANK_MAX_PASSAGE_CHARS = 4e3;
|
|
23
|
+
var knowledgeRankRequestSchema = z.object({
|
|
24
|
+
query: z.string().trim().min(1, "the question cannot be empty").max(2e3),
|
|
25
|
+
passages: z.array(z.string().max(KNOWLEDGE_RANK_MAX_PASSAGE_CHARS)).min(1).max(KNOWLEDGE_RANK_MAX_PASSAGES)
|
|
26
|
+
});
|
|
27
|
+
var knowledgeRankResponseSchema = z.object({
|
|
28
|
+
model: z.string(),
|
|
29
|
+
/** Every passage sent, best first. `index` points into the request's `passages`. */
|
|
30
|
+
ranking: z.array(z.object({ index: z.number().int().nonnegative(), score: z.number() }))
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// src/commands/knowledge/search.ts
|
|
34
|
+
import { defineCommand } from "citty";
|
|
35
|
+
import { z as z2 } from "zod";
|
|
36
|
+
var execFileAsync = promisify(execFile);
|
|
37
|
+
var QMD_TIMEOUT_MS = 9e4;
|
|
38
|
+
var PASSAGE_LINES = 70;
|
|
39
|
+
var SNIPPET_CHARS = 300;
|
|
40
|
+
var qmdRowSchema = z2.object({
|
|
41
|
+
file: z2.string(),
|
|
42
|
+
title: z2.string().optional(),
|
|
43
|
+
line: z2.number().int().optional(),
|
|
44
|
+
score: z2.number().default(0),
|
|
45
|
+
body: z2.string().default("")
|
|
46
|
+
});
|
|
47
|
+
function passageOf(body, line) {
|
|
48
|
+
const lines = body.split("\n");
|
|
49
|
+
const start = Math.max(0, (line ?? 1) - 1 - 5);
|
|
50
|
+
return lines.slice(start, start + PASSAGE_LINES).join("\n").slice(0, KNOWLEDGE_RANK_MAX_PASSAGE_CHARS);
|
|
51
|
+
}
|
|
52
|
+
function qmdQueryArgs(args) {
|
|
53
|
+
return [
|
|
54
|
+
"query",
|
|
55
|
+
args.question,
|
|
56
|
+
"--no-rerank",
|
|
57
|
+
"--json",
|
|
58
|
+
"--full",
|
|
59
|
+
"-n",
|
|
60
|
+
String(KNOWLEDGE_RANK_MAX_PASSAGES),
|
|
61
|
+
...args.collection ? ["-c", args.collection] : []
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
async function searchKnowledge(args, deps) {
|
|
65
|
+
const stdout = await deps.runQmd(qmdQueryArgs(args));
|
|
66
|
+
const rows = z2.array(qmdRowSchema).parse(JSON.parse(stdout));
|
|
67
|
+
if (rows.length === 0) {
|
|
68
|
+
return {
|
|
69
|
+
data: [],
|
|
70
|
+
meta: { count: 0, rankedBy: "qmd" },
|
|
71
|
+
hints: [
|
|
72
|
+
'Nothing in the vault answers this. Try an exact word with `qmd search "<word>"`, or check the collections with `qmd collection list`.'
|
|
73
|
+
]
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const passages = rows.map((row) => passageOf(row.body, row.line));
|
|
77
|
+
const ranked = await deps.rank({ query: args.question, passages }).catch(() => null);
|
|
78
|
+
const { model, ranking } = ranked ?? {
|
|
79
|
+
model: "qmd",
|
|
80
|
+
ranking: rows.map((row, index) => ({ index, score: row.score }))
|
|
81
|
+
};
|
|
82
|
+
const data = ranking.slice(0, args.limit).flatMap(({ index, score }) => {
|
|
83
|
+
const row = rows[index];
|
|
84
|
+
const passage = passages[index];
|
|
85
|
+
if (!row || passage === void 0) return [];
|
|
86
|
+
return [
|
|
87
|
+
{
|
|
88
|
+
file: row.file,
|
|
89
|
+
...row.title ? { title: row.title } : {},
|
|
90
|
+
...row.line ? { line: row.line } : {},
|
|
91
|
+
score: Math.round(score * 100) / 100,
|
|
92
|
+
snippet: passage.slice(0, SNIPPET_CHARS),
|
|
93
|
+
...args.full ? { passage } : {}
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
});
|
|
97
|
+
const hints = ranked ? [] : [
|
|
98
|
+
"Not ranked: the ranking model did not answer, so these are in qmd's own order. Read a few before trusting the first."
|
|
99
|
+
];
|
|
100
|
+
return { data, meta: { count: data.length, rankedBy: model }, hints };
|
|
101
|
+
}
|
|
102
|
+
var ARGS = {
|
|
103
|
+
question: {
|
|
104
|
+
type: "positional",
|
|
105
|
+
description: "The question, in plain words: what you want to know, not keywords",
|
|
106
|
+
required: true
|
|
107
|
+
},
|
|
108
|
+
collection: {
|
|
109
|
+
type: "string",
|
|
110
|
+
alias: "c",
|
|
111
|
+
description: "Only this qmd collection (names: qmd collection list)",
|
|
112
|
+
required: false
|
|
113
|
+
},
|
|
114
|
+
limit: {
|
|
115
|
+
type: "string",
|
|
116
|
+
alias: "n",
|
|
117
|
+
description: "Passages to return, 1-20 (default: 5)",
|
|
118
|
+
required: false
|
|
119
|
+
},
|
|
120
|
+
full: {
|
|
121
|
+
type: "boolean",
|
|
122
|
+
description: "Also return each passage's text (default: a 300-character snippet)",
|
|
123
|
+
required: false,
|
|
124
|
+
default: false
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
registerSchema({
|
|
128
|
+
command: "knowledge.search",
|
|
129
|
+
description: "Start here for a question about the company's Knowledge vault (src/content/): qmd finds the passages, a hosted model ranks them, best first, in about 10 seconds. Returns file (open it with `qmd get <file>`), line, score and a snippet. For an exact word, name or phrase use `qmd search` instead (instant).",
|
|
130
|
+
args: ARGS
|
|
131
|
+
});
|
|
132
|
+
function readLimit(raw) {
|
|
133
|
+
const limit = raw === void 0 ? 5 : Number(raw);
|
|
134
|
+
return Number.isInteger(limit) && limit >= 1 && limit <= 20 ? limit : 5;
|
|
135
|
+
}
|
|
136
|
+
var searchCommand = defineCommand({
|
|
137
|
+
meta: {
|
|
138
|
+
name: "search",
|
|
139
|
+
description: `Answer a question from the Knowledge vault: the best passages, ranked. Read-only, ~10 s.
|
|
140
|
+
|
|
141
|
+
Start here:
|
|
142
|
+
baker knowledge search "what budget did we start Meta prospecting with"
|
|
143
|
+
baker knowledge search "which hooks worked for retargeting" -c audits -n 10
|
|
144
|
+
|
|
145
|
+
Each hit: file (read it whole with \`qmd get <file>\`), line, score (0-1), snippet. --full adds the passage text.
|
|
146
|
+
For an exact word, name or phrase: \`qmd search "<words>"\` (instant).
|
|
147
|
+
Full guide: __tooling__/docs/tools/baker/knowledge.md`
|
|
148
|
+
},
|
|
149
|
+
args: ARGS,
|
|
150
|
+
run: async ({ args }) => {
|
|
151
|
+
try {
|
|
152
|
+
const { data, meta, hints } = await searchKnowledge(
|
|
153
|
+
{
|
|
154
|
+
question: String(args.question),
|
|
155
|
+
...typeof args.collection === "string" ? { collection: args.collection } : {},
|
|
156
|
+
limit: readLimit(args.limit),
|
|
157
|
+
full: args.full === true
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
runQmd: async (qmdArgs) => (await execFileAsync("qmd", qmdArgs, { timeout: QMD_TIMEOUT_MS, maxBuffer: 64 * 1024 * 1024 })).stdout,
|
|
161
|
+
rank: (request) => apiPost("/api/knowledge/rank", request, { timeoutMs: 2e4 })
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
writeJson({ ok: true, data, meta, ...hints.length > 0 ? { hints } : {} });
|
|
165
|
+
} catch (err) {
|
|
166
|
+
writeJson({
|
|
167
|
+
ok: false,
|
|
168
|
+
error: {
|
|
169
|
+
code: "UNAVAILABLE",
|
|
170
|
+
message: `The vault search did not run: ${err instanceof Error ? err.message.slice(0, 300) : "unknown error"}`,
|
|
171
|
+
fix: {
|
|
172
|
+
action: "degrade",
|
|
173
|
+
explanation: 'Search for an exact word instead with `qmd search "<word>"` (instant), or read the likely files under src/content/ directly. Do not retry in a loop.'
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// src/commands/knowledge/index.ts
|
|
183
|
+
var knowledgeCommand = defineCommand2({
|
|
184
|
+
meta: {
|
|
185
|
+
name: "knowledge",
|
|
186
|
+
description: "Search the company's Knowledge vault (src/content/): answers to a question, ranked best first."
|
|
187
|
+
},
|
|
188
|
+
subCommands: {
|
|
189
|
+
search: searchCommand
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
export {
|
|
193
|
+
knowledgeCommand
|
|
194
|
+
};
|
|
195
|
+
//# sourceMappingURL=knowledge-PKXPN4RV.js.map
|