@koda-sl/baker-cli 0.15.0 → 0.18.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 +469 -5
- package/dist/cli.js +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +3 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +4 -3
- package/dist/client.js.map +1 -1
- package/dist/commands/ads/google/accounts.d.ts.map +1 -1
- package/dist/commands/ads/google/accounts.js +7 -4
- package/dist/commands/ads/google/accounts.js.map +1 -1
- package/dist/commands/ads/google/index.d.ts.map +1 -1
- package/dist/commands/ads/google/index.js +5 -1
- package/dist/commands/ads/google/index.js.map +1 -1
- package/dist/commands/ads/google/library/index.d.ts +2 -0
- package/dist/commands/ads/google/library/index.d.ts.map +1 -0
- package/dist/commands/ads/google/library/index.js +271 -0
- package/dist/commands/ads/google/library/index.js.map +1 -0
- package/dist/commands/ads/output.d.ts +1 -0
- package/dist/commands/ads/output.d.ts.map +1 -1
- package/dist/commands/ads/output.js +18 -15
- package/dist/commands/ads/output.js.map +1 -1
- package/dist/commands/ga4/audit.d.ts +13 -0
- package/dist/commands/ga4/audit.d.ts.map +1 -0
- package/dist/commands/ga4/audit.js +67 -0
- package/dist/commands/ga4/audit.js.map +1 -0
- package/dist/commands/ga4/index.d.ts +2 -0
- package/dist/commands/ga4/index.d.ts.map +1 -0
- package/dist/commands/ga4/index.js +26 -0
- package/dist/commands/ga4/index.js.map +1 -0
- package/dist/commands/ga4/presets.d.ts +8 -0
- package/dist/commands/ga4/presets.d.ts.map +1 -0
- package/dist/commands/ga4/presets.js +33 -0
- package/dist/commands/ga4/presets.js.map +1 -0
- package/dist/commands/ga4/properties.d.ts +14 -0
- package/dist/commands/ga4/properties.d.ts.map +1 -0
- package/dist/commands/ga4/properties.js +61 -0
- package/dist/commands/ga4/properties.js.map +1 -0
- package/dist/commands/ga4/query.d.ts +69 -0
- package/dist/commands/ga4/query.d.ts.map +1 -0
- package/dist/commands/ga4/query.js +184 -0
- package/dist/commands/ga4/query.js.map +1 -0
- package/dist/commands/ga4/resolve.d.ts +2 -0
- package/dist/commands/ga4/resolve.d.ts.map +1 -0
- package/dist/commands/ga4/resolve.js +57 -0
- package/dist/commands/ga4/resolve.js.map +1 -0
- package/dist/commands/gsc/index.d.ts +2 -0
- package/dist/commands/gsc/index.d.ts.map +1 -0
- package/dist/commands/gsc/index.js +26 -0
- package/dist/commands/gsc/index.js.map +1 -0
- package/dist/commands/gsc/presets.d.ts +9 -0
- package/dist/commands/gsc/presets.d.ts.map +1 -0
- package/dist/commands/gsc/presets.js +34 -0
- package/dist/commands/gsc/presets.js.map +1 -0
- package/dist/commands/gsc/query.d.ts +79 -0
- package/dist/commands/gsc/query.d.ts.map +1 -0
- package/dist/commands/gsc/query.js +196 -0
- package/dist/commands/gsc/query.js.map +1 -0
- package/dist/commands/gsc/resolve.d.ts +2 -0
- package/dist/commands/gsc/resolve.d.ts.map +1 -0
- package/dist/commands/gsc/resolve.js +57 -0
- package/dist/commands/gsc/resolve.js.map +1 -0
- package/dist/commands/gsc/sitemaps.d.ts +19 -0
- package/dist/commands/gsc/sitemaps.d.ts.map +1 -0
- package/dist/commands/gsc/sitemaps.js +65 -0
- package/dist/commands/gsc/sitemaps.js.map +1 -0
- package/dist/commands/gsc/sites.d.ts +14 -0
- package/dist/commands/gsc/sites.d.ts.map +1 -0
- package/dist/commands/gsc/sites.js +61 -0
- package/dist/commands/gsc/sites.js.map +1 -0
- package/dist/commands/research/index.d.ts.map +1 -1
- package/dist/commands/research/index.js +7 -5
- package/dist/commands/research/index.js.map +1 -1
- package/dist/commands/research/web.d.ts +19 -0
- package/dist/commands/research/web.d.ts.map +1 -0
- package/dist/commands/research/web.js +112 -0
- package/dist/commands/research/web.js.map +1 -0
- package/dist/env.d.ts +2 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +2 -0
- package/dist/env.js.map +1 -1
- package/dist/error-handler.d.ts +8 -0
- package/dist/error-handler.d.ts.map +1 -0
- package/dist/error-handler.js +37 -0
- package/dist/error-handler.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { apiGet, apiPost } from "../../client.js";
|
|
3
|
+
import { registerSchema } from "../../schemas.js";
|
|
4
|
+
import { handleResearchError, writeResearchJson } from "./output.js";
|
|
5
|
+
registerSchema({
|
|
6
|
+
command: "research.web",
|
|
7
|
+
description: "Search the web with AI to answer marketing questions — competitors, ICP, pricing, pain points, market trends. Three depth levels: medium (quick, default), high (thorough), xhigh (exhaustive deep research).",
|
|
8
|
+
args: {
|
|
9
|
+
question: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "The research question to answer using live web data",
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
depth: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "Research depth: medium (quick), high (thorough), xhigh (exhaustive). Default: medium",
|
|
17
|
+
required: false,
|
|
18
|
+
enum: ["medium", "high", "xhigh"],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
const TIMEOUT_MS = {
|
|
23
|
+
medium: 180_000,
|
|
24
|
+
high: 360_000,
|
|
25
|
+
xhigh: 900_000,
|
|
26
|
+
};
|
|
27
|
+
const FIELDS = {
|
|
28
|
+
answer: "AI-generated research answer (markdown)",
|
|
29
|
+
sources: "Array of {title, url} sources used for grounding",
|
|
30
|
+
};
|
|
31
|
+
function sleep(ms) {
|
|
32
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
33
|
+
}
|
|
34
|
+
async function runDeepResearch(question) {
|
|
35
|
+
const { interactionId } = await apiPost("/api/research/deep-research/start", { question });
|
|
36
|
+
process.stderr.write(`Deep research started (${interactionId}). Polling...\n`);
|
|
37
|
+
const deadline = Date.now() + TIMEOUT_MS.xhigh;
|
|
38
|
+
while (Date.now() < deadline) {
|
|
39
|
+
await sleep(10_000);
|
|
40
|
+
const poll = await apiGet("/api/research/deep-research/poll", {
|
|
41
|
+
id: interactionId,
|
|
42
|
+
});
|
|
43
|
+
if (poll.status === "completed" && poll.result) {
|
|
44
|
+
return poll.result;
|
|
45
|
+
}
|
|
46
|
+
if (poll.status === "failed" || poll.status === "cancelled") {
|
|
47
|
+
throw new Error(`Deep research ${poll.status}`);
|
|
48
|
+
}
|
|
49
|
+
process.stderr.write(` status: ${poll.status}\n`);
|
|
50
|
+
}
|
|
51
|
+
throw new Error("Deep research timed out");
|
|
52
|
+
}
|
|
53
|
+
export const webCommand = defineCommand({
|
|
54
|
+
meta: {
|
|
55
|
+
name: "web",
|
|
56
|
+
description: `Search the web with AI to answer any open-ended marketing question. Uses live internet data via Google Search.
|
|
57
|
+
|
|
58
|
+
Depth levels:
|
|
59
|
+
medium — Quick lookup using Gemini Flash with minimal thinking (default)
|
|
60
|
+
high — Thorough answer using Gemini Flash with deep thinking
|
|
61
|
+
xhigh — Exhaustive deep research using Gemini Deep Research (slow, use sparingly)
|
|
62
|
+
|
|
63
|
+
Examples:
|
|
64
|
+
baker research web "Who are the main competitors of HubSpot CRM?"
|
|
65
|
+
baker research web "What are the top pain points for SMB CRM buyers?" --depth high
|
|
66
|
+
baker research web "Full competitive analysis of project management SaaS" --depth xhigh`,
|
|
67
|
+
},
|
|
68
|
+
args: {
|
|
69
|
+
question: { type: "positional", description: "The research question", required: true },
|
|
70
|
+
depth: { type: "string", description: "Research depth: medium|high|xhigh (default: medium)", required: false },
|
|
71
|
+
output: { type: "string", description: "Format: json|md (default: json)", required: false, default: "json" },
|
|
72
|
+
},
|
|
73
|
+
run: async ({ args }) => {
|
|
74
|
+
const question = args.question;
|
|
75
|
+
if (question.length < 5) {
|
|
76
|
+
writeResearchJson({
|
|
77
|
+
ok: false,
|
|
78
|
+
error: { code: "VALIDATION_ERROR", message: "Question must be at least 5 characters" },
|
|
79
|
+
});
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
const depth = (args.depth || "medium");
|
|
83
|
+
if (!["medium", "high", "xhigh"].includes(depth)) {
|
|
84
|
+
writeResearchJson({
|
|
85
|
+
ok: false,
|
|
86
|
+
error: { code: "VALIDATION_ERROR", message: "Depth must be one of: medium, high, xhigh" },
|
|
87
|
+
});
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const data = depth === "xhigh"
|
|
92
|
+
? await runDeepResearch(question)
|
|
93
|
+
: await apiPost("/api/research/explore", { question, depth }, { timeoutMs: TIMEOUT_MS[depth] });
|
|
94
|
+
const format = args.output || "json";
|
|
95
|
+
if (format === "md") {
|
|
96
|
+
process.stdout.write(`${data.answer}\n`);
|
|
97
|
+
if (data.sources.length > 0) {
|
|
98
|
+
process.stdout.write("\n## Sources\n");
|
|
99
|
+
for (const s of data.sources) {
|
|
100
|
+
process.stdout.write(`- [${s.title}](${s.url})\n`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
writeResearchJson({ ok: true, data, fields: FIELDS });
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
handleResearchError(err);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../../src/commands/research/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErE,cAAc,CAAC;IACb,OAAO,EAAE,cAAc;IACvB,WAAW,EACT,+MAA+M;IACjN,IAAI,EAAE;QACJ,QA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CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,mBAAmB,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
package/dist/env.d.ts
CHANGED
package/dist/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAGA,KAAK,GAAG,GAAG;IACT,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,4BAA4B,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAGA,KAAK,GAAG,GAAG;IACT,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAIF,wBAAgB,MAAM,IAAI,GAAG,CAiB5B"}
|
package/dist/env.js
CHANGED
package/dist/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,IAAI,MAAuB,CAAC;AAE5B,MAAM,UAAU,MAAM;IACpB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,SAAS,CAAC;YACjB,MAAM,EAAE;gBACN,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,+BAA+B,CAAC;gBAC5E,aAAa,EAAE,CAAC,CAAC,GAAG,CAAC,mCAAmC,CAAC;gBACzD,4BAA4B,EAAE,CAAC;qBAC5B,MAAM,EAAE;qBACR,KAAK,CAAC,UAAU,CAAC;qBACjB,QAAQ,EAAE;gBACb,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;gBAC5C,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;aAC1C;YACD,UAAU,EAAE,OAAO,CAAC,GAAG;SACxB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type ConnectionPlatform = "google_ads" | "ga4" | "gsc";
|
|
2
|
+
/**
|
|
3
|
+
* Shared error handler for "No Connection" scenarios.
|
|
4
|
+
* Provides a structured error for AI agents with a suggested fix and alternative commands.
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleConnectionError(platform: ConnectionPlatform, originalMessage?: string): never;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../src/error-handler.ts"],"names":[],"mappings":"AAEA,KAAK,kBAAkB,GAAG,YAAY,GAAG,KAAK,GAAG,KAAK,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,KAAK,CAkCnG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { writeJsonEnvelope } from "./commands/ads/output.js";
|
|
2
|
+
/**
|
|
3
|
+
* Shared error handler for "No Connection" scenarios.
|
|
4
|
+
* Provides a structured error for AI agents with a suggested fix and alternative commands.
|
|
5
|
+
*/
|
|
6
|
+
export function handleConnectionError(platform, originalMessage) {
|
|
7
|
+
const platformName = {
|
|
8
|
+
google_ads: "Google Ads",
|
|
9
|
+
ga4: "Google Analytics 4",
|
|
10
|
+
gsc: "Google Search Console",
|
|
11
|
+
}[platform];
|
|
12
|
+
const alternative = {
|
|
13
|
+
google_ads: "keywords-for-site or research advertisers",
|
|
14
|
+
ga4: "lighthouse for page performance",
|
|
15
|
+
gsc: "keywords-for-site or research keyword-gap",
|
|
16
|
+
}[platform];
|
|
17
|
+
const code = {
|
|
18
|
+
google_ads: "NO_GOOGLE_ADS_CONNECTION",
|
|
19
|
+
ga4: "NO_GA4_CONNECTION",
|
|
20
|
+
gsc: "NO_GSC_CONNECTION",
|
|
21
|
+
}[platform];
|
|
22
|
+
const envelope = {
|
|
23
|
+
ok: false,
|
|
24
|
+
error: {
|
|
25
|
+
code,
|
|
26
|
+
message: originalMessage || `No ${platformName} connection found for this company.`,
|
|
27
|
+
fix: {
|
|
28
|
+
action: "authenticate",
|
|
29
|
+
explanation: `AGENT INSTRUCTION: You cannot resolve this error programmatically. The user has not connected their ${platformName} account. Step 1: Inform the user that they must connect ${platformName} in their Baker dashboard settings for direct data queries. Step 2: Do not fail the overall audit or playbook. Document the missing connection, skip this specific check, and proceed with the rest of your tasks. (Optional fallback: use 'baker research ${alternative}' for estimated external insights).`,
|
|
30
|
+
},
|
|
31
|
+
retryable: false,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
writeJsonEnvelope(envelope);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../src/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAI7D;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAA4B,EAAE,eAAwB;IAC1F,MAAM,YAAY,GAAG;QACnB,UAAU,EAAE,YAAY;QACxB,GAAG,EAAE,oBAAoB;QACzB,GAAG,EAAE,uBAAuB;KAC7B,CAAC,QAAQ,CAAC,CAAC;IAEZ,MAAM,WAAW,GAAG;QAClB,UAAU,EAAE,2CAA2C;QACvD,GAAG,EAAE,iCAAiC;QACtC,GAAG,EAAE,2CAA2C;KACjD,CAAC,QAAQ,CAAC,CAAC;IAEZ,MAAM,IAAI,GAAG;QACX,UAAU,EAAE,0BAA0B;QACtC,GAAG,EAAE,mBAAmB;QACxB,GAAG,EAAE,mBAAmB;KACzB,CAAC,QAAQ,CAAC,CAAC;IAEZ,MAAM,QAAQ,GAAG;QACf,EAAE,EAAE,KAAK;QACT,KAAK,EAAE;YACL,IAAI;YACJ,OAAO,EAAE,eAAe,IAAI,MAAM,YAAY,qCAAqC;YACnF,GAAG,EAAE;gBACH,MAAM,EAAE,cAAc;gBACtB,WAAW,EAAE,uGAAuG,YAAY,4DAA4D,YAAY,8PAA8P,WAAW,qCAAqC;aACvf;YACD,SAAS,EAAE,KAAK;SACjB;KACF,CAAC;IAEF,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|