@koda-sl/baker-cli 0.5.1 → 0.11.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 +718 -162
- package/dist/cli.js +7 -3
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -1
- package/dist/client.js.map +1 -1
- package/dist/commands/ads/cache.d.ts +7 -0
- package/dist/commands/ads/cache.d.ts.map +1 -0
- package/dist/commands/ads/cache.js +73 -0
- package/dist/commands/ads/cache.js.map +1 -0
- package/dist/commands/ads/cache.test.d.ts +2 -0
- package/dist/commands/ads/cache.test.d.ts.map +1 -0
- package/dist/commands/ads/cache.test.js +44 -0
- package/dist/commands/ads/cache.test.js.map +1 -0
- package/dist/commands/ads/field-descriptions.d.ts +2 -0
- package/dist/commands/ads/field-descriptions.d.ts.map +1 -0
- package/dist/commands/ads/field-descriptions.js +91 -0
- package/dist/commands/ads/field-descriptions.js.map +1 -0
- package/dist/commands/ads/google/accounts.d.ts +14 -0
- package/dist/commands/ads/google/accounts.d.ts.map +1 -0
- package/dist/commands/ads/google/accounts.js +73 -0
- package/dist/commands/ads/google/accounts.js.map +1 -0
- package/dist/commands/ads/google/changes.d.ts +34 -0
- package/dist/commands/ads/google/changes.d.ts.map +1 -0
- package/dist/commands/ads/google/changes.js +80 -0
- package/dist/commands/ads/google/changes.js.map +1 -0
- package/dist/commands/ads/google/correction-table.d.ts +3 -0
- package/dist/commands/ads/google/correction-table.d.ts.map +1 -0
- package/dist/commands/ads/google/correction-table.js +340 -0
- package/dist/commands/ads/google/correction-table.js.map +1 -0
- package/dist/commands/ads/google/currency.d.ts +13 -0
- package/dist/commands/ads/google/currency.d.ts.map +1 -0
- package/dist/commands/ads/google/currency.js +68 -0
- package/dist/commands/ads/google/currency.js.map +1 -0
- package/dist/commands/ads/google/error-parser.d.ts +3 -0
- package/dist/commands/ads/google/error-parser.d.ts.map +1 -0
- package/dist/commands/ads/google/error-parser.js +91 -0
- package/dist/commands/ads/google/error-parser.js.map +1 -0
- package/dist/commands/ads/google/error-parser.test.d.ts +2 -0
- package/dist/commands/ads/google/error-parser.test.d.ts.map +1 -0
- package/dist/commands/ads/google/error-parser.test.js +48 -0
- package/dist/commands/ads/google/error-parser.test.js.map +1 -0
- package/dist/commands/ads/google/index.d.ts +2 -0
- package/dist/commands/ads/google/index.d.ts.map +1 -0
- package/dist/commands/ads/google/index.js +30 -0
- package/dist/commands/ads/google/index.js.map +1 -0
- package/dist/commands/ads/google/keywords/discover.d.ts +49 -0
- package/dist/commands/ads/google/keywords/discover.d.ts.map +1 -0
- package/dist/commands/ads/google/keywords/discover.js +139 -0
- package/dist/commands/ads/google/keywords/discover.js.map +1 -0
- package/dist/commands/ads/google/keywords/index.d.ts +2 -0
- package/dist/commands/ads/google/keywords/index.d.ts.map +1 -0
- package/dist/commands/ads/google/keywords/index.js +18 -0
- package/dist/commands/ads/google/keywords/index.js.map +1 -0
- package/dist/commands/ads/google/keywords/metrics.d.ts +34 -0
- package/dist/commands/ads/google/keywords/metrics.d.ts.map +1 -0
- package/dist/commands/ads/google/keywords/metrics.js +111 -0
- package/dist/commands/ads/google/keywords/metrics.js.map +1 -0
- package/dist/commands/ads/google/preflight.d.ts +3 -0
- package/dist/commands/ads/google/preflight.d.ts.map +1 -0
- package/dist/commands/ads/google/preflight.js +115 -0
- package/dist/commands/ads/google/preflight.js.map +1 -0
- package/dist/commands/ads/google/preflight.test.d.ts +2 -0
- package/dist/commands/ads/google/preflight.test.d.ts.map +1 -0
- package/dist/commands/ads/google/preflight.test.js +50 -0
- package/dist/commands/ads/google/preflight.test.js.map +1 -0
- package/dist/commands/ads/google/presets.d.ts +12 -0
- package/dist/commands/ads/google/presets.d.ts.map +1 -0
- package/dist/commands/ads/google/presets.js +71 -0
- package/dist/commands/ads/google/presets.js.map +1 -0
- package/dist/commands/ads/google/presets.test.d.ts +2 -0
- package/dist/commands/ads/google/presets.test.d.ts.map +1 -0
- package/dist/commands/ads/google/presets.test.js +79 -0
- package/dist/commands/ads/google/presets.test.js.map +1 -0
- package/dist/commands/ads/google/query.d.ts +64 -0
- package/dist/commands/ads/google/query.d.ts.map +1 -0
- package/dist/commands/ads/google/query.js +304 -0
- package/dist/commands/ads/google/query.js.map +1 -0
- package/dist/commands/ads/index.d.ts +2 -0
- package/dist/commands/ads/index.d.ts.map +1 -0
- package/dist/commands/ads/index.js +19 -0
- package/dist/commands/ads/index.js.map +1 -0
- package/dist/commands/ads/output.d.ts +17 -0
- package/dist/commands/ads/output.d.ts.map +1 -0
- package/dist/commands/ads/output.js +78 -0
- package/dist/commands/ads/output.js.map +1 -0
- package/dist/commands/ads/output.test.d.ts +2 -0
- package/dist/commands/ads/output.test.d.ts.map +1 -0
- package/dist/commands/ads/output.test.js +100 -0
- package/dist/commands/ads/output.test.js.map +1 -0
- package/dist/commands/ads/types.d.ts +69 -0
- package/dist/commands/ads/types.d.ts.map +1 -0
- package/dist/commands/ads/types.js +2 -0
- package/dist/commands/ads/types.js.map +1 -0
- package/dist/commands/research/advertisers.d.ts +34 -0
- package/dist/commands/research/advertisers.d.ts.map +1 -0
- package/dist/commands/research/advertisers.js +75 -0
- package/dist/commands/research/advertisers.js.map +1 -0
- package/dist/commands/research/countries.d.ts +2 -0
- package/dist/commands/research/countries.d.ts.map +1 -0
- package/dist/commands/research/countries.js +69 -0
- package/dist/commands/research/countries.js.map +1 -0
- package/dist/commands/research/index.d.ts +2 -0
- package/dist/commands/research/index.d.ts.map +1 -0
- package/dist/commands/research/index.js +40 -0
- package/dist/commands/research/index.js.map +1 -0
- package/dist/commands/research/intent.d.ts +24 -0
- package/dist/commands/research/intent.d.ts.map +1 -0
- package/dist/commands/research/intent.js +71 -0
- package/dist/commands/research/intent.js.map +1 -0
- package/dist/commands/research/keyword-gap.d.ts +49 -0
- package/dist/commands/research/keyword-gap.d.ts.map +1 -0
- package/dist/commands/research/keyword-gap.js +99 -0
- package/dist/commands/research/keyword-gap.js.map +1 -0
- package/dist/commands/research/keywords-for-site.d.ts +44 -0
- package/dist/commands/research/keywords-for-site.d.ts.map +1 -0
- package/dist/commands/research/keywords-for-site.js +83 -0
- package/dist/commands/research/keywords-for-site.js.map +1 -0
- package/dist/commands/research/languages.d.ts +2 -0
- package/dist/commands/research/languages.d.ts.map +1 -0
- package/dist/commands/research/languages.js +42 -0
- package/dist/commands/research/languages.js.map +1 -0
- package/dist/commands/research/lighthouse.d.ts +24 -0
- package/dist/commands/research/lighthouse.d.ts.map +1 -0
- package/dist/commands/research/lighthouse.js +60 -0
- package/dist/commands/research/lighthouse.js.map +1 -0
- package/dist/commands/research/output.d.ts +29 -0
- package/dist/commands/research/output.d.ts.map +1 -0
- package/dist/commands/research/output.js +81 -0
- package/dist/commands/research/output.js.map +1 -0
- package/dist/env.d.ts +1 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +5 -1
- package/dist/env.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getEnv } from "../../env.js";
|
|
2
|
+
export function writeAdsJson(envelope) {
|
|
3
|
+
process.stdout.write(`${JSON.stringify(envelope, null, 2)}\n`);
|
|
4
|
+
}
|
|
5
|
+
export function toCsvRow(values) {
|
|
6
|
+
return values
|
|
7
|
+
.map((v) => {
|
|
8
|
+
if (v.includes(",") || v.includes('"') || v.includes("\n")) {
|
|
9
|
+
return `"${v.replace(/"/g, '""')}"`;
|
|
10
|
+
}
|
|
11
|
+
return v;
|
|
12
|
+
})
|
|
13
|
+
.join(",");
|
|
14
|
+
}
|
|
15
|
+
function flattenRow(row) {
|
|
16
|
+
const flat = {};
|
|
17
|
+
for (const [key, val] of Object.entries(row)) {
|
|
18
|
+
flat[key] = typeof val === "object" && val !== null ? JSON.stringify(val) : String(val ?? "");
|
|
19
|
+
}
|
|
20
|
+
return flat;
|
|
21
|
+
}
|
|
22
|
+
function writeAdsCsv(data, fields) {
|
|
23
|
+
if (data.length === 0)
|
|
24
|
+
return;
|
|
25
|
+
const cols = fields ?? Object.keys(data[0] ?? {});
|
|
26
|
+
process.stdout.write(`${toCsvRow(cols)}\n`);
|
|
27
|
+
for (const row of data) {
|
|
28
|
+
const flat = flattenRow(row);
|
|
29
|
+
process.stdout.write(`${toCsvRow(cols.map((f) => flat[f] ?? ""))}\n`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function writeAdsJsonl(data) {
|
|
33
|
+
for (const row of data) {
|
|
34
|
+
process.stdout.write(`${JSON.stringify(row)}\n`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function writeAdsMd(data, fields) {
|
|
38
|
+
if (data.length === 0)
|
|
39
|
+
return;
|
|
40
|
+
const cols = fields ?? Object.keys(data[0] ?? {});
|
|
41
|
+
process.stdout.write(`| ${cols.join(" | ")} |\n`);
|
|
42
|
+
process.stdout.write(`| ${cols.map(() => "---").join(" | ")} |\n`);
|
|
43
|
+
for (const row of data) {
|
|
44
|
+
const flat = flattenRow(row);
|
|
45
|
+
process.stdout.write(`| ${cols.map((f) => flat[f] ?? "").join(" | ")} |\n`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function writeAdsOutput(data, format, fields) {
|
|
49
|
+
switch (format) {
|
|
50
|
+
case "csv":
|
|
51
|
+
writeAdsCsv(data, fields);
|
|
52
|
+
break;
|
|
53
|
+
case "jsonl":
|
|
54
|
+
writeAdsJsonl(data);
|
|
55
|
+
break;
|
|
56
|
+
case "md":
|
|
57
|
+
writeAdsMd(data, fields);
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
writeAdsJson({ ok: true, data });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function resolveCustomerId(args) {
|
|
64
|
+
const fromArgs = args["customer-id"];
|
|
65
|
+
const customerId = fromArgs || getEnv().BAKER_GOOGLE_ADS_CUSTOMER_ID;
|
|
66
|
+
if (!customerId || !/^\d{10}$/.test(customerId)) {
|
|
67
|
+
writeAdsJson({
|
|
68
|
+
ok: false,
|
|
69
|
+
error: {
|
|
70
|
+
code: "INVALID_CUSTOMER_ID",
|
|
71
|
+
message: "Customer ID must be exactly 10 digits without dashes. Pass --customer-id or set BAKER_GOOGLE_ADS_CUSTOMER_ID.",
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
return customerId;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../../src/commands/ads/output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAUtC,MAAM,UAAU,YAAY,CAAC,QAAmB;IAC9C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,MAAgB;IACvC,OAAO,MAAM;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3D,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;QACtC,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,GAA4B;IAC9C,MAAM,IAAI,GAA2B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,IAAI,CAAC,GAA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AAE,CAAC;QAChD,YAAY,CAAC;YACX,EAAE,EAAE,KAAK;YACT,KAAK,EAAE;gBACL,IAAI,EAAE,qBAAqB;gBAC3B,OAAO,EACL,+GAA+G;aAClH;SACF,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.test.d.ts","sourceRoot":"","sources":["../../../src/commands/ads/output.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { toCsvRow, writeAdsJson, writeAdsOutput } from "./output.js";
|
|
3
|
+
describe("toCsvRow", () => {
|
|
4
|
+
it("joins simple values with commas", () => {
|
|
5
|
+
expect(toCsvRow(["a", "b", "c"])).toBe("a,b,c");
|
|
6
|
+
});
|
|
7
|
+
it("wraps values containing commas in double quotes", () => {
|
|
8
|
+
expect(toCsvRow(["hello, world", "plain"])).toBe('"hello, world",plain');
|
|
9
|
+
});
|
|
10
|
+
it("wraps values containing double quotes and escapes them", () => {
|
|
11
|
+
expect(toCsvRow(['say "hi"'])).toBe('"say ""hi"""');
|
|
12
|
+
});
|
|
13
|
+
it("wraps values containing newlines in double quotes", () => {
|
|
14
|
+
expect(toCsvRow(["line1\nline2"])).toBe('"line1\nline2"');
|
|
15
|
+
});
|
|
16
|
+
it("handles empty values", () => {
|
|
17
|
+
expect(toCsvRow(["", "a", ""])).toBe(",a,");
|
|
18
|
+
});
|
|
19
|
+
it("handles a single value", () => {
|
|
20
|
+
expect(toCsvRow(["only"])).toBe("only");
|
|
21
|
+
});
|
|
22
|
+
it("handles values with both commas and quotes", () => {
|
|
23
|
+
expect(toCsvRow(['value "with", special'])).toBe('"value ""with"", special"');
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe("writeAdsJson", () => {
|
|
27
|
+
let writeSpy;
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
writeSpy = vi.spyOn(process.stdout, "write").mockReturnValue(true);
|
|
30
|
+
});
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
writeSpy.mockRestore();
|
|
33
|
+
});
|
|
34
|
+
it("outputs JSON with trailing newline", () => {
|
|
35
|
+
writeAdsJson({ ok: true, data: { message: "test" } });
|
|
36
|
+
expect(writeSpy).toHaveBeenCalledTimes(1);
|
|
37
|
+
const output = writeSpy.mock.calls[0]?.[0];
|
|
38
|
+
expect(output.endsWith("\n")).toBe(true);
|
|
39
|
+
expect(JSON.parse(output)).toEqual({ ok: true, data: { message: "test" } });
|
|
40
|
+
});
|
|
41
|
+
it("pretty-prints with 2-space indentation", () => {
|
|
42
|
+
writeAdsJson({ ok: true, data: [1] });
|
|
43
|
+
const output = writeSpy.mock.calls[0]?.[0];
|
|
44
|
+
expect(output).toContain(" ");
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe("writeAdsOutput", () => {
|
|
48
|
+
let writeSpy;
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
writeSpy = vi.spyOn(process.stdout, "write").mockReturnValue(true);
|
|
51
|
+
});
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
writeSpy.mockRestore();
|
|
54
|
+
});
|
|
55
|
+
it("outputs CSV with header row and data rows", () => {
|
|
56
|
+
writeAdsOutput([{ name: "Campaign A", clicks: 100 }], "csv");
|
|
57
|
+
const output = writeSpy.mock.calls.map((c) => c[0]).join("");
|
|
58
|
+
const lines = output.trim().split("\n");
|
|
59
|
+
expect(lines[0]).toBe("name,clicks");
|
|
60
|
+
expect(lines[1]).toBe("Campaign A,100");
|
|
61
|
+
});
|
|
62
|
+
it("outputs CSV with specified field order", () => {
|
|
63
|
+
writeAdsOutput([{ name: "Campaign A", clicks: 100 }], "csv", ["clicks", "name"]);
|
|
64
|
+
const output = writeSpy.mock.calls.map((c) => c[0]).join("");
|
|
65
|
+
const lines = output.trim().split("\n");
|
|
66
|
+
expect(lines[0]).toBe("clicks,name");
|
|
67
|
+
expect(lines[1]).toBe("100,Campaign A");
|
|
68
|
+
});
|
|
69
|
+
it("outputs JSONL with one JSON object per line", () => {
|
|
70
|
+
writeAdsOutput([{ id: 1 }, { id: 2 }], "jsonl");
|
|
71
|
+
const output = writeSpy.mock.calls.map((c) => c[0]).join("");
|
|
72
|
+
const lines = output.trim().split("\n");
|
|
73
|
+
expect(JSON.parse(lines[0] ?? "")).toEqual({ id: 1 });
|
|
74
|
+
expect(JSON.parse(lines[1] ?? "")).toEqual({ id: 2 });
|
|
75
|
+
});
|
|
76
|
+
it("outputs markdown table format", () => {
|
|
77
|
+
writeAdsOutput([{ name: "Test", value: "42" }], "md");
|
|
78
|
+
const output = writeSpy.mock.calls.map((c) => c[0]).join("");
|
|
79
|
+
expect(output).toContain("| name | value |");
|
|
80
|
+
expect(output).toContain("| --- | --- |");
|
|
81
|
+
expect(output).toContain("| Test | 42 |");
|
|
82
|
+
});
|
|
83
|
+
it("falls back to JSON for unknown format", () => {
|
|
84
|
+
writeAdsOutput([{ id: 1 }], "unknown");
|
|
85
|
+
const output = writeSpy.mock.calls.map((c) => c[0]).join("");
|
|
86
|
+
const parsed = JSON.parse(output);
|
|
87
|
+
expect(parsed.ok).toBe(true);
|
|
88
|
+
expect(parsed.data).toEqual([{ id: 1 }]);
|
|
89
|
+
});
|
|
90
|
+
it("handles empty data arrays for CSV", () => {
|
|
91
|
+
writeAdsOutput([], "csv");
|
|
92
|
+
expect(writeSpy).not.toHaveBeenCalled();
|
|
93
|
+
});
|
|
94
|
+
it("flattens nested objects to JSON strings in CSV", () => {
|
|
95
|
+
writeAdsOutput([{ name: "A", details: { foo: "bar" } }], "csv");
|
|
96
|
+
const output = writeSpy.mock.calls.map((c) => c[0]).join("");
|
|
97
|
+
expect(output).toContain('"{""foo"":""bar""}"');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
//# sourceMapp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;QAClC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAC1B,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAEhE,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAY,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxE,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
type FixAction = "retry_with_modified_query" | "retry_with_flag" | "use_different_resource" | "add_required_field" | "change_operator" | "narrow_date_range" | "split_query" | "authenticate" | "wait_and_retry" | "reject";
|
|
2
|
+
export interface QueryFix {
|
|
3
|
+
action: FixAction;
|
|
4
|
+
correctedCommand?: string;
|
|
5
|
+
explanation: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AdsWarning {
|
|
8
|
+
code: string;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
export interface AdsSuccessEnvelope<T> {
|
|
12
|
+
ok: true;
|
|
13
|
+
data: T;
|
|
14
|
+
fields?: Record<string, string>;
|
|
15
|
+
pagination?: {
|
|
16
|
+
hasMore: boolean;
|
|
17
|
+
cursor: string;
|
|
18
|
+
};
|
|
19
|
+
warnings?: AdsWarning[];
|
|
20
|
+
cached?: true;
|
|
21
|
+
}
|
|
22
|
+
export interface AdsErrorEnvelope {
|
|
23
|
+
ok: false;
|
|
24
|
+
error: {
|
|
25
|
+
code: string;
|
|
26
|
+
message: string;
|
|
27
|
+
fix: QueryFix;
|
|
28
|
+
retryable: boolean;
|
|
29
|
+
retryAfterMs?: number;
|
|
30
|
+
gaqlExecuted?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface AdsFileSummary {
|
|
34
|
+
ok: true;
|
|
35
|
+
fields: Record<string, string>;
|
|
36
|
+
file: string;
|
|
37
|
+
rows: number;
|
|
38
|
+
cached?: true;
|
|
39
|
+
}
|
|
40
|
+
export interface CorrectionContext {
|
|
41
|
+
originalQuery: string;
|
|
42
|
+
customerId: string;
|
|
43
|
+
apiErrorMessage?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface CorrectionRule {
|
|
46
|
+
matchQuery?: RegExp;
|
|
47
|
+
matchApiError?: RegExp;
|
|
48
|
+
fix: (ctx: CorrectionContext) => QueryFix;
|
|
49
|
+
}
|
|
50
|
+
export interface PreflightResult {
|
|
51
|
+
valid: boolean;
|
|
52
|
+
error?: AdsErrorEnvelope;
|
|
53
|
+
correctedQuery?: string;
|
|
54
|
+
warnings: AdsWarning[];
|
|
55
|
+
}
|
|
56
|
+
export interface CacheEntry<T> {
|
|
57
|
+
expiresAt: number;
|
|
58
|
+
data: T;
|
|
59
|
+
fields?: Record<string, string>;
|
|
60
|
+
}
|
|
61
|
+
export interface PresetDefinition {
|
|
62
|
+
name: string;
|
|
63
|
+
description: string;
|
|
64
|
+
gaqlTemplate: string;
|
|
65
|
+
defaultDateRange: string;
|
|
66
|
+
defaultLimit: number;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/ads/types.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GACV,2BAA2B,GAC3B,iBAAiB,GACjB,wBAAwB,GACxB,oBAAoB,GACpB,iBAAiB,GACjB,mBAAmB,GACnB,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,QAAQ,CAAC;AAEb,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,SAAS,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,UAAU,CAAC,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,IAAI,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,GAAG,EAAE,QAAQ,CAAC;QACd,SAAS,EAAE,OAAO,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,IAAI,CAAC;IACT,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,QAAQ,CAAC;CAC3C;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/commands/ads/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const advertisersCommand: import("citty").CommandDef<{
|
|
2
|
+
readonly keyword: {
|
|
3
|
+
readonly type: "positional";
|
|
4
|
+
readonly description: "Keyword to search";
|
|
5
|
+
readonly required: true;
|
|
6
|
+
};
|
|
7
|
+
readonly location: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly description: "Country code or location code (default: us)";
|
|
10
|
+
readonly required: false;
|
|
11
|
+
};
|
|
12
|
+
readonly language: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly description: "Language code or name (default: en)";
|
|
15
|
+
readonly required: false;
|
|
16
|
+
};
|
|
17
|
+
readonly limit: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly description: "Max results (default: 20, max: 100)";
|
|
20
|
+
readonly required: false;
|
|
21
|
+
};
|
|
22
|
+
readonly output: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly description: "Format: json|csv|md|jsonl";
|
|
25
|
+
readonly required: false;
|
|
26
|
+
readonly default: "json";
|
|
27
|
+
};
|
|
28
|
+
readonly "no-cache": {
|
|
29
|
+
readonly type: "boolean";
|
|
30
|
+
readonly description: "Skip server cache, hit API directly";
|
|
31
|
+
readonly required: false;
|
|
32
|
+
};
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=advertisers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advertisers.d.ts","sourceRoot":"","sources":["../../../src/commands/research/advertisers.ts"],"names":[],"mappings":"AA0CA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4C7B,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { apiPost } from "../../client.js";
|
|
3
|
+
import { registerSchema } from "../../schemas.js";
|
|
4
|
+
import { handleResearchError, RESEARCH_DATA_NOTE, writeResearchJson, writeResearchOutput } from "./output.js";
|
|
5
|
+
registerSchema({
|
|
6
|
+
command: "research.advertisers",
|
|
7
|
+
description: "Find domains competing for a keyword in Google SERPs. Shows who's competing for the same search term with their visibility and estimated traffic.",
|
|
8
|
+
args: {
|
|
9
|
+
keyword: { type: "string", description: "Keyword to search (positional)", required: true },
|
|
10
|
+
location: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "Country code (us, uk, es, de...) or DataForSEO location code. Default: us",
|
|
13
|
+
required: false,
|
|
14
|
+
},
|
|
15
|
+
language: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Language code or name (en, es, spanish...). Default: en",
|
|
18
|
+
required: false,
|
|
19
|
+
},
|
|
20
|
+
limit: { type: "string", description: "Max results (default: 20, max: 100)", required: false },
|
|
21
|
+
"no-cache": { type: "boolean", description: "Skip server cache, hit API directly", required: false },
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const FIELDS = {
|
|
25
|
+
domain: "Competing domain",
|
|
26
|
+
avg_position: "Average SERP position (1 = top)",
|
|
27
|
+
rating: "Domain relevance rating (0-100)",
|
|
28
|
+
etv: "Estimated traffic value (USD)",
|
|
29
|
+
visibility: "SERP visibility score (0-1)",
|
|
30
|
+
};
|
|
31
|
+
export const advertisersCommand = defineCommand({
|
|
32
|
+
meta: {
|
|
33
|
+
name: "advertisers",
|
|
34
|
+
description: `Find domains competing for a keyword in Google SERPs.
|
|
35
|
+
|
|
36
|
+
Examples:
|
|
37
|
+
baker research advertisers "running shoes"
|
|
38
|
+
baker research advertisers "crm software" --location uk --limit 10
|
|
39
|
+
baker research advertisers "zapatos" --location es --language spanish`,
|
|
40
|
+
},
|
|
41
|
+
args: {
|
|
42
|
+
keyword: { type: "positional", description: "Keyword to search", required: true },
|
|
43
|
+
location: { type: "string", description: "Country code or location code (default: us)", required: false },
|
|
44
|
+
language: { type: "string", description: "Language code or name (default: en)", required: false },
|
|
45
|
+
limit: { type: "string", description: "Max results (default: 20, max: 100)", required: false },
|
|
46
|
+
output: { type: "string", description: "Format: json|csv|md|jsonl", required: false, default: "json" },
|
|
47
|
+
"no-cache": { type: "boolean", description: "Skip server cache, hit API directly", required: false },
|
|
48
|
+
},
|
|
49
|
+
run: async ({ args }) => {
|
|
50
|
+
const keyword = args.keyword;
|
|
51
|
+
const location = args.location || undefined;
|
|
52
|
+
const language = args.language || undefined;
|
|
53
|
+
const limit = args.limit ? Number(args.limit) : undefined;
|
|
54
|
+
const skipCache = args["no-cache"] ? true : undefined;
|
|
55
|
+
try {
|
|
56
|
+
const data = await apiPost("/api/research/advertisers", {
|
|
57
|
+
keyword,
|
|
58
|
+
location,
|
|
59
|
+
language,
|
|
60
|
+
limit,
|
|
61
|
+
skipCache,
|
|
62
|
+
});
|
|
63
|
+
const format = args.output || "json";
|
|
64
|
+
if (format !== "json") {
|
|
65
|
+
writeResearchOutput(data, format);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
writeResearchJson({ ok: true, data, fields: FIELDS, note: RESEARCH_DATA_NOTE });
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
handleResearchError(err);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=advertisers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advertisers.js","sourceRoot":"","sources":["../../../src/commands/research/advertisers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE9G,cAAc,CAAC;IACb,OAAO,EAAE,sBAAsB;IAC/B,WAAW,EACT,mJAAmJ;IACrJ,IAAI,EAAE;QACJ,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gCAAgC,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC1F,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,2EAA2E;Y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"AA+DA,eAAO,MAAM,gBAAgB,qDAQ3B,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { registerSchema } from "../../schemas.js";
|
|
3
|
+
import { writeResearchJson } from "./output.js";
|
|
4
|
+
registerSchema({
|
|
5
|
+
command: "research.countries",
|
|
6
|
+
description: "List all supported country codes for --location flag in research commands.",
|
|
7
|
+
args: {},
|
|
8
|
+
});
|
|
9
|
+
const COUNTRIES = [
|
|
10
|
+
{ code: "us", name: "United States" },
|
|
11
|
+
{ code: "uk", name: "United Kingdom" },
|
|
12
|
+
{ code: "ca", name: "Canada" },
|
|
13
|
+
{ code: "au", name: "Australia" },
|
|
14
|
+
{ code: "de", name: "Germany" },
|
|
15
|
+
{ code: "fr", name: "France" },
|
|
16
|
+
{ code: "es", name: "Spain" },
|
|
17
|
+
{ code: "it", name: "Italy" },
|
|
18
|
+
{ code: "br", name: "Brazil" },
|
|
19
|
+
{ code: "mx", name: "Mexico" },
|
|
20
|
+
{ code: "nl", name: "Netherlands" },
|
|
21
|
+
{ code: "be", name: "Belgium" },
|
|
22
|
+
{ code: "at", name: "Austria" },
|
|
23
|
+
{ code: "ch", name: "Switzerland" },
|
|
24
|
+
{ code: "pt", name: "Portugal" },
|
|
25
|
+
{ code: "se", name: "Sweden" },
|
|
26
|
+
{ code: "no", name: "Norway" },
|
|
27
|
+
{ code: "dk", name: "Denmark" },
|
|
28
|
+
{ code: "fi", name: "Finland" },
|
|
29
|
+
{ code: "ie", name: "Ireland" },
|
|
30
|
+
{ code: "nz", name: "New Zealand" },
|
|
31
|
+
{ code: "in", name: "India" },
|
|
32
|
+
{ code: "jp", name: "Japan" },
|
|
33
|
+
{ code: "kr", name: "South Korea" },
|
|
34
|
+
{ code: "sg", name: "Singapore" },
|
|
35
|
+
{ code: "ar", name: "Argentina" },
|
|
36
|
+
{ code: "cl", name: "Chile" },
|
|
37
|
+
{ code: "co", name: "Colombia" },
|
|
38
|
+
{ code: "pe", name: "Peru" },
|
|
39
|
+
{ code: "pl", name: "Poland" },
|
|
40
|
+
{ code: "cz", name: "Czech Republic" },
|
|
41
|
+
{ code: "ro", name: "Romania" },
|
|
42
|
+
{ code: "hu", name: "Hungary" },
|
|
43
|
+
{ code: "za", name: "South Africa" },
|
|
44
|
+
{ code: "il", name: "Israel" },
|
|
45
|
+
{ code: "ae", name: "United Arab Emirates" },
|
|
46
|
+
{ code: "sa", name: "Saudi Arabia" },
|
|
47
|
+
{ code: "tr", name: "Turkey" },
|
|
48
|
+
{ code: "ph", name: "Philippines" },
|
|
49
|
+
{ code: "th", name: "Thailand" },
|
|
50
|
+
{ code: "my", name: "Malaysia" },
|
|
51
|
+
{ code: "id", name: "Indonesia" },
|
|
52
|
+
{ code: "vn", name: "Vietnam" },
|
|
53
|
+
{ code: "tw", name: "Taiwan" },
|
|
54
|
+
{ code: "hk", name: "Hong Kong" },
|
|
55
|
+
];
|
|
56
|
+
const FIELDS = {
|
|
57
|
+
code: "Country code to pass as --location",
|
|
58
|
+
name: "Country name",
|
|
59
|
+
};
|
|
60
|
+
export const countriesCommand = defineCommand({
|
|
61
|
+
meta: {
|
|
62
|
+
name: "countries",
|
|
63
|
+
description: "List all supported country codes for --location flag.",
|
|
64
|
+
},
|
|
65
|
+
run: () => {
|
|
66
|
+
writeResearchJson({ ok: true, data: COUNTRIES, fields: FIELDS });
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=countries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countries.js","sourceRoot":"","sources":["../../../src/commands/research/countries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,cAAc,CAAC;IACb,OAAO,EAAE,oBAAoB;IAC7B,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AE,aAAa,EAAE;IACnC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE;IAChC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE;IAChC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE;IACjC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;IAC/B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9B,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE;CAClC,CAAC;AAEF,MAAM,MAAM,GAA2B;IACrC,IAAI,EAAE,oCAAoC;IAC1C,IAAI,EAAE,cAAc;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;IAC5C,IAAI,EAAE;QACJ,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,uDAAuD;KACrE;IACD,GAAG,EAAE,GAAG,EAAE;QACR,iBAAiB,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACnE,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/research/index.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,eAAe,qDA8B1B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { advertisersCommand } from "./advertisers.js";
|
|
3
|
+
import { countriesCommand } from "./countries.js";
|
|
4
|
+
import { intentCommand } from "./intent.js";
|
|
5
|
+
import { keywordGapCommand } from "./keyword-gap.js";
|
|
6
|
+
import { keywordsForSiteCommand } from "./keywords-for-site.js";
|
|
7
|
+
import { languagesCommand } from "./languages.js";
|
|
8
|
+
import { lighthouseCommand } from "./lighthouse.js";
|
|
9
|
+
export const researchCommand = defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: "research",
|
|
12
|
+
description: `Competitive intelligence commands powered by DataForSEO. Shows market/competitor data — who's bidding on keywords, search intent, competitor keyword lists, keyword gaps, and landing page performance.
|
|
13
|
+
|
|
14
|
+
Commands:
|
|
15
|
+
advertisers — Who's bidding on a keyword?
|
|
16
|
+
intent — Google Search intent classification
|
|
17
|
+
keywords-for-site — Keywords a domain bids on
|
|
18
|
+
keyword-gap — Keywords they have that we don't
|
|
19
|
+
lighthouse — Landing page performance audit
|
|
20
|
+
countries — List supported country codes
|
|
21
|
+
languages — List supported language codes
|
|
22
|
+
|
|
23
|
+
Examples:
|
|
24
|
+
baker research advertisers "running shoes"
|
|
25
|
+
baker research intent "buy running shoes,best running shoes 2026"
|
|
26
|
+
baker research keywords-for-site "competitor.com"
|
|
27
|
+
baker research keyword-gap "them.com" "us.com"
|
|
28
|
+
baker research lighthouse "https://example.com/landing"`,
|
|
29
|
+
},
|
|
30
|
+
subCommands: {
|
|
31
|
+
advertisers: advertisersCommand,
|
|
32
|
+
countries: countriesCommand,
|
|
33
|
+
intent: intentCommand,
|
|
34
|
+
"keywords-for-site": keywordsForSiteCommand,
|
|
35
|
+
"keyword-gap": keywordGapCommand,
|
|
36
|
+
languages: languagesCommand,
|
|
37
|
+
lighthouse: lighthouseCommand,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/research/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;IAC3C,IAAI,EAAE;QACJ,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE;;;;;;;;;;;;;;;;0DAgByC;KACvD;IACD,WAAW,EAAE;QACX,WAAW,EAAE,kBAAkB;QAC/B,SAAS,EAAE,gBAAgB;QAC3B,MAAM,EAAE,aAAa;QACrB,mBAAmB,EAAE,sBAAsB;QAC3C,aAAa,EAAE,iBAAiB;QAChC,SAAS,EAAE,gBAAgB;QAC3B,UAAU,EAAE,iBAAiB;KAC9B;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const intentCommand: import("citty").CommandDef<{
|
|
2
|
+
readonly keywords: {
|
|
3
|
+
readonly type: "positional";
|
|
4
|
+
readonly description: "Comma-separated keywords";
|
|
5
|
+
readonly required: true;
|
|
6
|
+
};
|
|
7
|
+
readonly language: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly description: "Language code or name (default: en)";
|
|
10
|
+
readonly required: false;
|
|
11
|
+
};
|
|
12
|
+
readonly output: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly description: "Format: json|csv|md|jsonl";
|
|
15
|
+
readonly required: false;
|
|
16
|
+
readonly default: "json";
|
|
17
|
+
};
|
|
18
|
+
readonly "no-cache": {
|
|
19
|
+
readonly type: "boolean";
|
|
20
|
+
readonly description: "Skip server cache, hit API directly";
|
|
21
|
+
readonly required: false;
|
|
22
|
+
};
|
|
23
|
+
}>;
|
|
24
|
+
//# sourceMappingURL=intent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../../../src/commands/research/intent.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;EAkDxB,CAAC"}
|