@mimeticinc/mim-cli 0.1.2 → 0.1.3

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.
@@ -5,7 +5,7 @@ import {
5
5
  mimAuthToken,
6
6
  normalizeMimApiBaseUrl,
7
7
  trackMimUsageEvent
8
- } from "./chunk-RXBIMVUG.js";
8
+ } from "./chunk-UHJPAJVG.js";
9
9
 
10
10
  // src/mim-mcp-stdio.ts
11
11
  import { randomUUID } from "crypto";
@@ -21,6 +21,8 @@ Commands:
21
21
  recordings List recent session recording summaries.
22
22
  replay [session_id] Print one persisted replay insight. Defaults to latest.
23
23
  findings List audit/backlog findings from TryMimetic.
24
+ query-ga4 Query your connected GA4 (needs --metrics, e.g. sessions).
25
+ query-gsc Query your connected Search Console (top queries/pages).
24
26
  audit start <url> Start an audit, reusing a running/completed audit when available.
25
27
  audit rerun <url> Force a fresh audit for a site that was already audited.
26
28
  audit status <audit_id> Check audit progress.
@@ -616,6 +618,87 @@ async function runCollectionCommand(command, args) {
616
618
  else if (command === "recordings") console.log(formatRecordingsPayload(payload, { project: resolvedProject }));
617
619
  else console.log(formatMimListPayload(payload, command));
618
620
  }
621
+ function buildQueryToolArgs(tool, project, rest) {
622
+ const toolArgs = { project };
623
+ let metrics = [];
624
+ let dimensions = [];
625
+ for (let i = 0; i < rest.length; i += 1) {
626
+ const arg = rest[i];
627
+ if (arg === "--metrics") {
628
+ const [value, next] = readValue(rest, i, arg);
629
+ metrics = value.split(",").map((s) => s.trim()).filter(Boolean);
630
+ i = next;
631
+ } else if (arg === "--dimensions" || arg === "--dims") {
632
+ const [value, next] = readValue(rest, i, arg);
633
+ dimensions = value.split(",").map((s) => s.trim()).filter(Boolean);
634
+ i = next;
635
+ } else if (arg === "--start-date" || arg === "--start") {
636
+ const [value, next] = readValue(rest, i, arg);
637
+ toolArgs.start_date = value;
638
+ i = next;
639
+ } else if (arg === "--end-date" || arg === "--end") {
640
+ const [value, next] = readValue(rest, i, arg);
641
+ toolArgs.end_date = value;
642
+ i = next;
643
+ } else if (arg === "--limit") {
644
+ const [value, next] = readValue(rest, i, arg);
645
+ const n = Number(value);
646
+ if (!Number.isInteger(n) || n <= 0) throw new Error("--limit must be a positive integer");
647
+ if (tool === "query_gsc") toolArgs.row_limit = n;
648
+ else toolArgs.limit = n;
649
+ i = next;
650
+ } else if (arg === "--order-by") {
651
+ const [value, next] = readValue(rest, i, arg);
652
+ toolArgs.order_by_metric = value;
653
+ i = next;
654
+ } else {
655
+ throw new Error(`unknown ${tool} option: ${arg}`);
656
+ }
657
+ }
658
+ if (metrics.length) toolArgs.metrics = metrics;
659
+ if (dimensions.length) toolArgs.dimensions = dimensions;
660
+ if (tool === "query_ga4" && !metrics.length) {
661
+ throw new Error("query-ga4 requires --metrics (e.g. --metrics sessions,conversions)");
662
+ }
663
+ return toolArgs;
664
+ }
665
+ async function runQuery(tool, args) {
666
+ const { runtime, args: kept, project } = runtimeFromArgs(args);
667
+ requireAuth(runtime);
668
+ const resolvedProject = requireProject(project);
669
+ const parsedFormat = parseFormat(kept, "json");
670
+ const toolArgs = buildQueryToolArgs(tool, resolvedProject, parsedFormat.args);
671
+ const body = { jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: tool, arguments: toolArgs } };
672
+ const response = await runTrackedMimCommand(
673
+ runtime,
674
+ {
675
+ command: tool,
676
+ project: resolvedProject,
677
+ metadata: {
678
+ metrics: Array.isArray(toolArgs.metrics) ? toolArgs.metrics.length : 0,
679
+ dimensions: Array.isArray(toolArgs.dimensions) ? toolArgs.dimensions.length : 0
680
+ }
681
+ },
682
+ () => mimRequest(
683
+ runtime,
684
+ "/api/mim/mcp",
685
+ { body }
686
+ )
687
+ );
688
+ if (response?.error) throw new Error(response.error.message || "request failed");
689
+ const result = response?.result;
690
+ const text = result?.content?.[0]?.text ?? "";
691
+ let parsed = text;
692
+ try {
693
+ parsed = JSON.parse(text);
694
+ } catch {
695
+ }
696
+ if (result?.isError) {
697
+ const message = parsed && typeof parsed === "object" && "error" in parsed ? String(parsed.error) : String(parsed);
698
+ throw new Error(message || "query failed");
699
+ }
700
+ printJson(parsed);
701
+ }
619
702
  async function runReplay(args) {
620
703
  const { runtime, args: kept, project } = runtimeFromArgs(args);
621
704
  requireAuth(runtime);
@@ -1141,6 +1224,8 @@ async function mimMain(argv = process.argv.slice(2)) {
1141
1224
  if (command === "recordings") return runCollectionCommand("recordings", args);
1142
1225
  if (command === "replay") return runReplay(args);
1143
1226
  if (command === "findings") return runCollectionCommand("findings", args);
1227
+ if (command === "query-ga4") return runQuery("query_ga4", args);
1228
+ if (command === "query-gsc") return runQuery("query_gsc", args);
1144
1229
  if (command === "audit") return runAudit(args);
1145
1230
  if (command === "web-audit") return runWebAudit(args);
1146
1231
  if (command === "ipa-audit") return runIpaAudit(args);
@@ -1174,6 +1259,7 @@ export {
1174
1259
  formatMimListPayload,
1175
1260
  formatRecordingsPayload,
1176
1261
  formatReplayInsightPayload,
1262
+ buildQueryToolArgs,
1177
1263
  formatFixesPayload,
1178
1264
  claudeMcpInstallCommand,
1179
1265
  codexMcpConfig,
package/dist/mim-bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  mimMain
4
- } from "./chunk-RXBIMVUG.js";
4
+ } from "./chunk-UHJPAJVG.js";
5
5
 
6
6
  // src/mim-bin.ts
7
7
  mimMain().catch((error) => {
package/dist/mim-cli.d.ts CHANGED
@@ -91,9 +91,10 @@ declare function formatRecordingsPayload(payload: unknown, options?: {
91
91
  project?: string;
92
92
  }): string;
93
93
  declare function formatReplayInsightPayload(payload: unknown): string;
94
+ declare function buildQueryToolArgs(tool: "query_ga4" | "query_gsc", project: string, rest: string[]): Record<string, unknown>;
94
95
  declare function formatFixesPayload(payload: FixesResponse): string;
95
96
  declare function claudeMcpInstallCommand(project?: string): string[];
96
97
  declare function codexMcpConfig(project?: string): string;
97
98
  declare function mimMain(argv?: string[]): Promise<void>;
98
99
 
99
- export { type MimConfig, type MimRuntime, buildMimUsageEvent, claudeMcpInstallCommand, clearMimConfig, codexMcpConfig, defaultMimProject, formatFixesPayload, formatMimListPayload, formatRecordingsPayload, formatReplayInsightPayload, loadMimConfig, mimApiBaseUrl, mimAuthToken, mimConfigDir, mimConfigPath, mimMain, mimUsage, normalizeMimApiBaseUrl, sanitizeMimMetadata, saveMimConfig, shouldSendMimTelemetry, trackMimUsageEvent };
100
+ export { type MimConfig, type MimRuntime, buildMimUsageEvent, buildQueryToolArgs, claudeMcpInstallCommand, clearMimConfig, codexMcpConfig, defaultMimProject, formatFixesPayload, formatMimListPayload, formatRecordingsPayload, formatReplayInsightPayload, loadMimConfig, mimApiBaseUrl, mimAuthToken, mimConfigDir, mimConfigPath, mimMain, mimUsage, normalizeMimApiBaseUrl, sanitizeMimMetadata, saveMimConfig, shouldSendMimTelemetry, trackMimUsageEvent };
package/dist/mim-cli.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  buildMimUsageEvent,
4
+ buildQueryToolArgs,
4
5
  claudeMcpInstallCommand,
5
6
  clearMimConfig,
6
7
  codexMcpConfig,
@@ -21,9 +22,10 @@ import {
21
22
  saveMimConfig,
22
23
  shouldSendMimTelemetry,
23
24
  trackMimUsageEvent
24
- } from "./chunk-RXBIMVUG.js";
25
+ } from "./chunk-UHJPAJVG.js";
25
26
  export {
26
27
  buildMimUsageEvent,
28
+ buildQueryToolArgs,
27
29
  claudeMcpInstallCommand,
28
30
  clearMimConfig,
29
31
  codexMcpConfig,
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runMimMcpStdio
4
- } from "./chunk-CQR3GJV6.js";
5
- import "./chunk-RXBIMVUG.js";
4
+ } from "./chunk-MS74BAYV.js";
5
+ import "./chunk-UHJPAJVG.js";
6
6
 
7
7
  // src/mim-mcp-bin.ts
8
8
  try {
@@ -4,8 +4,8 @@ import {
4
4
  parseMimMcpOptions,
5
5
  proxyMimMcpMessage,
6
6
  runMimMcpStdio
7
- } from "./chunk-CQR3GJV6.js";
8
- import "./chunk-RXBIMVUG.js";
7
+ } from "./chunk-MS74BAYV.js";
8
+ import "./chunk-UHJPAJVG.js";
9
9
  export {
10
10
  mimMcpUsage,
11
11
  parseMimMcpOptions,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mimeticinc/mim-cli",
3
- "version": "0.1.2",
4
- "description": "Mimetic CLI growth context for Claude Code, Codex, and shell workflows",
3
+ "version": "0.1.3",
4
+ "description": "Mimetic CLI \u2014 growth context for Claude Code, Codex, and shell workflows",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Mimetic Inc.",
@@ -56,4 +56,4 @@
56
56
  "typescript": "^5.7.0",
57
57
  "vitest": "^3.2.0"
58
58
  }
59
- }
59
+ }