@withgauge/cli 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +18 -3
  2. package/dist/index.js +735 -105
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @withgauge/cli
2
2
 
3
- `gauge` — the [Gauge](https://withgauge.com) command-line interface. Manage
3
+ `gauge` — the [Gauge](https://agents.withgauge.com) command-line interface. Manage
4
4
  your prompts, repositories, and agent runs, and watch runs live from your
5
5
  terminal.
6
6
 
@@ -18,12 +18,27 @@ Requires Node.js ≥ 22.12.
18
18
  gauge prompts list # your prompts
19
19
  gauge runs list --status running # recent & active runs
20
20
  gauge runs watch <run-id> # follow a run as the agent works
21
+ gauge runs fork <run-id> --prompt "Try a different approach"
21
22
  gauge repos list # your repository catalog
23
+ gauge stats rankings -o json # brand rankings (share of voice) as JSON
24
+ gauge query fields --dataset installs # discover a dataset's dimensions/metrics
25
+ gauge query -d ecosystem -m installs,install_rate -o json # a flexible report
22
26
  ```
23
27
 
24
28
  Run `gauge --help` (or `gauge <command> --help`) for the full command set:
25
- prompts, schedules, repos, runs, brands, tags, topics, provider keys,
26
- billing, and more.
29
+ prompts, schedules, repos, runs, stats, query, brands, tags, topics, provider
30
+ keys, billing, and more.
31
+
32
+ `gauge query` builds flexible reports over your event warehouse (a GA4
33
+ `run_report` analog): pick a `--dataset`, group by `--dimensions`, and aggregate
34
+ `--metrics`, or pass a whole spec with `--json` (the agent-friendly surface).
35
+ `gauge query datasets` / `gauge query fields --dataset <name>` list what you can
36
+ ask for.
37
+
38
+ To launch runs declaratively, `gauge apply -f <spec>.json`. Discover the spec
39
+ format without leaving the terminal: `gauge apply --example` prints a starter
40
+ spec (`gauge apply --example > battery.json`), and `gauge apply --schema` prints
41
+ its JSON Schema.
27
42
 
28
43
  Every read supports `-o json` for scripting. `GAUGE_API_TOKEN` overrides
29
44
  stored credentials (useful in CI). Exit codes: `0` ok · `1` error ·
package/dist/index.js CHANGED
@@ -16,6 +16,30 @@ __export(apply_exports, {
16
16
  import { readFileSync as readFileSync3 } from "fs";
17
17
 
18
18
  // ../packages/api-schemas/src/batteries.ts
19
+ var batteries_exports = {};
20
+ __export(batteries_exports, {
21
+ BATTERY_AGENTS: () => BATTERY_AGENTS,
22
+ BATTERY_CADENCES: () => BATTERY_CADENCES,
23
+ BATTERY_MAX_LIMITS: () => BATTERY_MAX_LIMITS,
24
+ BATTERY_SCENARIOS: () => BATTERY_SCENARIOS,
25
+ MAX_SAMPLES_PER_CYCLE: () => MAX_SAMPLES_PER_CYCLE,
26
+ batchDetailSchema: () => batchDetailSchema,
27
+ batchListQuerySchema: () => batchListQuerySchema,
28
+ batchListResponseSchema: () => batchListResponseSchema,
29
+ batchRunStatusSchema: () => batchRunStatusSchema,
30
+ batchRunSummarySchema: () => batchRunSummarySchema,
31
+ batchSummarySchema: () => batchSummarySchema,
32
+ batteryAgentSchema: () => batteryAgentSchema,
33
+ batteryApplyResponseSchema: () => batteryApplyResponseSchema,
34
+ batteryDefaultsSchema: () => batteryDefaultsSchema,
35
+ batteryLimitsSchema: () => batteryLimitsSchema,
36
+ batteryPlanPromptSchema: () => batteryPlanPromptSchema,
37
+ batteryPlanScheduleSchema: () => batteryPlanScheduleSchema,
38
+ batteryPlanSchema: () => batteryPlanSchema,
39
+ batteryPromptSpecSchema: () => batteryPromptSpecSchema,
40
+ batteryScheduleSpecSchema: () => batteryScheduleSpecSchema,
41
+ batterySpecSchema: () => batterySpecSchema
42
+ });
19
43
  import { z as z2 } from "zod";
20
44
 
21
45
  // ../packages/api-schemas/src/common.ts
@@ -504,63 +528,235 @@ var runPromptResponseSchema = z10.object({
504
528
  blocked: z10.enum(["insufficient_credits", "needs_provider_key"]).optional()
505
529
  });
506
530
 
507
- // ../packages/api-schemas/src/repos.ts
531
+ // ../packages/api-schemas/src/query.ts
532
+ import { z as z12 } from "zod";
533
+
534
+ // ../packages/api-schemas/src/stats.ts
508
535
  import { z as z11 } from "zod";
536
+ var BRAND_KINDS2 = ["OWNED", "COMPETITOR", "OTHER"];
537
+ var brandKindSchema2 = z11.enum(BRAND_KINDS2);
538
+ var brandRankingSchema = z11.object({
539
+ rank: z11.number().int(),
540
+ brandId: z11.string(),
541
+ brandName: z11.string(),
542
+ kind: brandKindSchema2,
543
+ installs: z11.number().int(),
544
+ installRate: z11.number(),
545
+ mentionRate: z11.number(),
546
+ /** Movement between the two most recent batch windows; null if not ranked in both. */
547
+ deltaRank: z11.number().int().nullable()
548
+ });
549
+ var packageRateSchema = z11.object({
550
+ ecosystem: z11.string(),
551
+ name: z11.string(),
552
+ brandName: z11.string().optional(),
553
+ kind: brandKindSchema2.optional(),
554
+ installs: z11.number().int(),
555
+ rate: z11.number()
556
+ });
557
+ var brandRateSchema = z11.object({
558
+ brandId: z11.string(),
559
+ brandName: z11.string(),
560
+ kind: brandKindSchema2,
561
+ installs: z11.number().int(),
562
+ rate: z11.number()
563
+ });
564
+ var brandFunnelRowSchema = z11.object({
565
+ brandId: z11.string(),
566
+ brandName: z11.string(),
567
+ kind: brandKindSchema2,
568
+ mentionRate: z11.number(),
569
+ installRate: z11.number()
570
+ });
571
+ var domainRateSchema = z11.object({
572
+ domain: z11.string(),
573
+ runs: z11.number().int(),
574
+ rate: z11.number(),
575
+ requests: z11.number().int(),
576
+ brandName: z11.string().optional(),
577
+ owned: z11.boolean().optional()
578
+ });
579
+ var statsFreshnessSchema = z11.object({
580
+ /** Newest run-ingest time across the org (ISO), or null if nothing ingested. */
581
+ watermark: z11.string().nullable(),
582
+ /** Runs that succeeded recently but haven't landed in the warehouse yet. */
583
+ pending: z11.number().int(),
584
+ /** False when the freshness read itself failed (distinguish from genuine zero). */
585
+ available: z11.boolean()
586
+ });
587
+ var statsResponseSchema = (item) => z11.object({ items: z11.array(item), freshness: statsFreshnessSchema });
588
+ var rankingsResponseSchema = statsResponseSchema(brandRankingSchema);
589
+ var installsResponseSchema = statsResponseSchema(packageRateSchema);
590
+ var brandsResponseSchema = statsResponseSchema(brandRateSchema);
591
+ var funnelResponseSchema = statsResponseSchema(brandFunnelRowSchema);
592
+ var domainsResponseSchema = statsResponseSchema(domainRateSchema);
593
+
594
+ // ../packages/api-schemas/src/query.ts
595
+ var DATASETS = [
596
+ "runs",
597
+ "installs",
598
+ "mentions",
599
+ "web",
600
+ "network",
601
+ "files",
602
+ "tokens"
603
+ ];
604
+ var datasetSchema = z12.enum(DATASETS);
605
+ var WHERE_OPS = [
606
+ "eq",
607
+ "neq",
608
+ "in",
609
+ "notIn",
610
+ "contains",
611
+ "gt",
612
+ "gte",
613
+ "lt",
614
+ "lte"
615
+ ];
616
+ var whereOpSchema = z12.enum(WHERE_OPS);
617
+ var GRANULARITIES = ["day", "week", "month"];
618
+ var granularitySchema = z12.enum(GRANULARITIES);
619
+ var DEFAULT_QUERY_LIMIT = 50;
620
+ var MAX_QUERY_LIMIT = 1e3;
621
+ var scalar = z12.union([z12.string(), z12.number(), z12.boolean()]);
622
+ var whereClauseSchema = z12.object({
623
+ dimension: z12.string().min(1),
624
+ op: whereOpSchema,
625
+ value: z12.union([scalar, z12.array(scalar)])
626
+ });
627
+ var queryFiltersSchema = z12.object({
628
+ prompt: z12.string(),
629
+ topic: z12.array(z12.string()),
630
+ tag: z12.array(z12.string()),
631
+ repo: z12.array(z12.string()),
632
+ language: z12.array(z12.string()),
633
+ framework: z12.array(z12.string()),
634
+ size: z12.array(z12.string()),
635
+ agent: z12.array(z12.string()),
636
+ model: z12.array(z12.string()),
637
+ scenario: z12.array(z12.string()),
638
+ experiment: z12.array(z12.string()),
639
+ branded: z12.boolean()
640
+ }).partial();
641
+ var dateRangeSchema = z12.object({
642
+ since: z12.string(),
643
+ until: z12.string(),
644
+ lastDays: z12.number().int().positive()
645
+ }).partial();
646
+ var orderBySchema = z12.object({
647
+ /** A selected dimension or metric name. */
648
+ key: z12.string().min(1),
649
+ dir: z12.enum(["asc", "desc"]).default("desc")
650
+ });
651
+ var querySpecSchema = z12.object({
652
+ dataset: datasetSchema.default("runs"),
653
+ dimensions: z12.array(z12.string()).default([]),
654
+ metrics: z12.array(z12.string()).min(1, "at least one metric is required"),
655
+ filters: queryFiltersSchema.default({}),
656
+ where: z12.array(whereClauseSchema).default([]),
657
+ dateRange: dateRangeSchema.optional(),
658
+ orderBy: z12.array(orderBySchema).default([]),
659
+ limit: z12.number().int().min(1).max(MAX_QUERY_LIMIT).default(DEFAULT_QUERY_LIMIT),
660
+ granularity: granularitySchema.default("day"),
661
+ /** When true, the response echoes the compiled SQL (params bound, not inlined). */
662
+ explain: z12.boolean().default(false)
663
+ });
664
+ var columnKindSchema = z12.enum(["dimension", "metric"]);
665
+ var queryColumnSchema = z12.object({
666
+ key: z12.string(),
667
+ kind: columnKindSchema
668
+ });
669
+ var queryRowSchema = z12.record(
670
+ z12.string(),
671
+ z12.union([z12.string(), z12.number(), z12.boolean(), z12.null()])
672
+ );
673
+ var queryResponseSchema = z12.object({
674
+ columns: z12.array(queryColumnSchema),
675
+ rows: z12.array(queryRowSchema),
676
+ /** Present only when the request set explain=true. */
677
+ sql: z12.string().optional(),
678
+ freshness: statsFreshnessSchema
679
+ });
680
+ var fieldTypeSchema = z12.enum([
681
+ "string",
682
+ "number",
683
+ "rate",
684
+ "date",
685
+ "boolean"
686
+ ]);
687
+ var fieldSchema = z12.object({
688
+ name: z12.string(),
689
+ type: fieldTypeSchema,
690
+ /** One-line human/agent hint. */
691
+ description: z12.string().optional()
692
+ });
693
+ var datasetMetaSchema = z12.object({
694
+ name: datasetSchema,
695
+ grain: z12.string(),
696
+ dimensions: z12.array(fieldSchema),
697
+ metrics: z12.array(fieldSchema)
698
+ });
699
+ var metadataResponseSchema = z12.object({
700
+ datasets: z12.array(datasetMetaSchema)
701
+ });
702
+
703
+ // ../packages/api-schemas/src/repos.ts
704
+ import { z as z13 } from "zod";
509
705
  var REPO_SIZE_BUCKETS = [
510
706
  "small",
511
707
  "medium",
512
708
  "large",
513
709
  "xlarge"
514
710
  ];
515
- var repoSizeBucketSchema = z11.enum(REPO_SIZE_BUCKETS);
516
- var repoSchema = z11.object({
517
- url: z11.string(),
518
- name: z11.string(),
519
- isSystem: z11.boolean(),
520
- languages: z11.array(z11.string()),
521
- frameworks: z11.array(z11.string()),
711
+ var repoSizeBucketSchema = z13.enum(REPO_SIZE_BUCKETS);
712
+ var repoSchema = z13.object({
713
+ url: z13.string(),
714
+ name: z13.string(),
715
+ isSystem: z13.boolean(),
716
+ languages: z13.array(z13.string()),
717
+ frameworks: z13.array(z13.string()),
522
718
  /** Faceted labels (complexity:L2, buildable:yes, stack:nextjs, …). */
523
- tags: z11.array(z11.string()),
524
- primaryLanguage: z11.string(),
525
- sizeKb: z11.number(),
719
+ tags: z13.array(z13.string()),
720
+ primaryLanguage: z13.string(),
721
+ sizeKb: z13.number(),
526
722
  sizeBucket: repoSizeBucketSchema.nullable(),
527
- stars: z11.number()
723
+ stars: z13.number()
528
724
  });
529
725
  var repoListResponseSchema = listResponseSchema(repoSchema);
530
- var addRepoBodySchema = z11.object({
531
- url: z11.string().min(1, "url is required"),
726
+ var addRepoBodySchema = z13.object({
727
+ url: z13.string().min(1, "url is required"),
532
728
  /**
533
729
  * Reserved (accepted, not yet persisted): the catalog keys repos by URL only
534
730
  * — `fact_repo` has no ref column and metadata sync always reads the default
535
731
  * branch. Kept in the wire format so `gauge repos add --ref` is stable once
536
732
  * the catalog learns refs.
537
733
  */
538
- ref: z11.string().min(1).optional(),
734
+ ref: z13.string().min(1).optional(),
539
735
  /** Display name; defaults to the `owner/repo` label of the URL. */
540
- name: z11.string().min(1).optional(),
736
+ name: z13.string().min(1).optional(),
541
737
  /** Manual override; defaults to frameworks detected from the repo's manifests. */
542
- frameworks: z11.array(z11.string()).optional(),
543
- tags: z11.array(z11.string()).optional()
738
+ frameworks: z13.array(z13.string()).optional(),
739
+ tags: z13.array(z13.string()).optional()
544
740
  });
545
- var updateRepoBodySchema = z11.object({
546
- url: z11.string().min(1, "url is required"),
547
- name: z11.string().min(1).optional(),
548
- frameworks: z11.array(z11.string()).optional(),
549
- tags: z11.array(z11.string()).optional()
741
+ var updateRepoBodySchema = z13.object({
742
+ url: z13.string().min(1, "url is required"),
743
+ name: z13.string().min(1).optional(),
744
+ frameworks: z13.array(z13.string()).optional(),
745
+ tags: z13.array(z13.string()).optional()
550
746
  });
551
- var resyncRepoBodySchema = z11.object({
552
- url: z11.string().min(1, "url is required")
747
+ var resyncRepoBodySchema = z13.object({
748
+ url: z13.string().min(1, "url is required")
553
749
  });
554
- var deleteRepoQuerySchema = z11.object({
555
- url: z11.string().min(1, "url is required")
750
+ var deleteRepoQuerySchema = z13.object({
751
+ url: z13.string().min(1, "url is required")
556
752
  });
557
- var repoSyncResultSchema = z11.object({
753
+ var repoSyncResultSchema = z13.object({
558
754
  repo: repoSchema,
559
- synced: z11.boolean()
755
+ synced: z13.boolean()
560
756
  });
561
757
 
562
758
  // ../packages/api-schemas/src/runs.ts
563
- import { z as z12 } from "zod";
759
+ import { z as z14 } from "zod";
564
760
  var RUN_STATUSES = [
565
761
  "QUEUED",
566
762
  "CLAIMED",
@@ -571,89 +767,103 @@ var RUN_STATUSES = [
571
767
  "TIMED_OUT",
572
768
  "CANCELED"
573
769
  ];
574
- var runStatusSchema = z12.enum(RUN_STATUSES);
770
+ var runStatusSchema = z14.enum(RUN_STATUSES);
575
771
  var AGENTS2 = ["CLAUDE_CODE", "CODEX_CLI", "CURSOR"];
576
- var agentSchema2 = z12.enum(AGENTS2);
577
- var runStatusFilterSchema = z12.string().transform(
772
+ var agentSchema2 = z14.enum(AGENTS2);
773
+ var runStatusFilterSchema = z14.string().transform(
578
774
  (raw) => raw.split(",").map((s) => s.trim().toUpperCase()).filter(Boolean)
579
- ).pipe(z12.array(runStatusSchema).min(1));
775
+ ).pipe(z14.array(runStatusSchema).min(1));
580
776
  var runListQuerySchema = listQuerySchema.extend({
581
777
  status: runStatusFilterSchema.optional(),
582
- batch: z12.string().optional(),
583
- prompt: z12.string().optional(),
584
- experiment: z12.string().optional(),
585
- since: z12.string().optional()
778
+ batch: z14.string().optional(),
779
+ prompt: z14.string().optional(),
780
+ experiment: z14.string().optional(),
781
+ since: z14.string().optional()
586
782
  });
587
- var runListItemSchema = z12.object({
588
- id: z12.string(),
783
+ var runListItemSchema = z14.object({
784
+ id: z14.string(),
589
785
  status: runStatusSchema,
590
786
  agent: agentSchema2,
591
- model: z12.string(),
592
- promptId: z12.string(),
787
+ model: z14.string(),
788
+ promptId: z14.string(),
593
789
  /** First ~80 chars of the batch's prompt snapshot, whitespace-collapsed. */
594
- promptSnippet: z12.string(),
595
- batchId: z12.string(),
596
- experiment: z12.string().nullable(),
597
- turns: z12.number().int().nullable(),
598
- usdCost: z12.number().nullable(),
599
- durationMs: z12.number().int().nullable(),
600
- exitReason: z12.string().nullable(),
601
- createdAt: z12.string(),
602
- startedAt: z12.string().nullable(),
603
- finishedAt: z12.string().nullable()
790
+ promptSnippet: z14.string(),
791
+ batchId: z14.string(),
792
+ experiment: z14.string().nullable(),
793
+ turns: z14.number().int().nullable(),
794
+ usdCost: z14.number().nullable(),
795
+ durationMs: z14.number().int().nullable(),
796
+ exitReason: z14.string().nullable(),
797
+ createdAt: z14.string(),
798
+ startedAt: z14.string().nullable(),
799
+ finishedAt: z14.string().nullable()
604
800
  });
605
801
  var runListResponseSchema = listResponseSchema(runListItemSchema);
606
802
  var runDetailSchema = runListItemSchema.omit({ promptSnippet: true }).extend({
607
- promptText: z12.string(),
608
- attempt: z12.number().int(),
609
- cancelRequested: z12.boolean(),
610
- failureReason: z12.string().nullable(),
611
- repoUrl: z12.string().nullable(),
612
- repoRef: z12.string().nullable(),
613
- scenario: z12.string(),
614
- funding: z12.string(),
803
+ promptText: z14.string(),
804
+ attempt: z14.number().int(),
805
+ cancelRequested: z14.boolean(),
806
+ failureReason: z14.string().nullable(),
807
+ repoUrl: z14.string().nullable(),
808
+ repoRef: z14.string().nullable(),
809
+ scenario: z14.string(),
810
+ funding: z14.string(),
615
811
  /** Raw harness usage write-back (token counts etc.); shape may evolve. */
616
- usage: z12.unknown().nullable(),
812
+ usage: z14.unknown().nullable(),
617
813
  /** Artifact pointer: a working-tree diff exists at GET /runs/{id}/diff. */
618
- hasDiff: z12.boolean(),
619
- claimedAt: z12.string().nullable()
814
+ hasDiff: z14.boolean(),
815
+ claimedAt: z14.string().nullable()
620
816
  });
621
- var cancelRunResponseSchema = z12.object({
622
- id: z12.string(),
817
+ var cancelRunResponseSchema = z14.object({
818
+ id: z14.string(),
623
819
  status: runStatusSchema,
624
- cancelRequested: z12.boolean(),
625
- note: z12.string().optional()
626
- });
627
- var runEventSchema = z12.looseObject({
628
- run_id: z12.string(),
629
- seq: z12.number(),
630
- turn: z12.number(),
631
- ts: z12.string(),
632
- type: z12.string()
820
+ cancelRequested: z14.boolean(),
821
+ note: z14.string().optional()
822
+ });
823
+ var forkRunBodySchema = z14.object({
824
+ prompt: z14.string().trim().min(1).max(2e4),
825
+ turn: z14.number().int().min(0).optional()
826
+ });
827
+ var forkRunResponseSchema = z14.object({
828
+ runId: z14.string(),
829
+ batchId: z14.string(),
830
+ parentRunId: z14.string(),
831
+ checkpointId: z14.string(),
832
+ turn: z14.number().int().min(0)
833
+ });
834
+ var runEventSchema = z14.looseObject({
835
+ run_id: z14.string(),
836
+ seq: z14.number(),
837
+ turn: z14.number(),
838
+ ts: z14.string(),
839
+ type: z14.string()
633
840
  });
634
841
 
635
842
  // ../packages/api-schemas/src/tokens.ts
636
- import { z as z13 } from "zod";
637
- var apiTokenSchema = z13.object({
638
- id: z13.string(),
639
- name: z13.string(),
843
+ import { z as z15 } from "zod";
844
+ var apiTokenSchema = z15.object({
845
+ id: z15.string(),
846
+ name: z15.string(),
640
847
  /** Last 4 chars of the plaintext, for recognizability (non-secret). */
641
- last4: z13.string(),
642
- expiresAt: z13.iso.datetime().nullable(),
643
- lastUsedAt: z13.iso.datetime().nullable(),
644
- createdAt: z13.iso.datetime(),
645
- revokedAt: z13.iso.datetime().nullable()
646
- });
647
- var createTokenRequestSchema = z13.object({
648
- name: z13.string().min(1).max(100),
848
+ last4: z15.string(),
849
+ expiresAt: z15.iso.datetime().nullable(),
850
+ lastUsedAt: z15.iso.datetime().nullable(),
851
+ createdAt: z15.iso.datetime(),
852
+ revokedAt: z15.iso.datetime().nullable()
853
+ });
854
+ var createTokenRequestSchema = z15.object({
855
+ name: z15.string().min(1).max(100),
649
856
  /** ISO-8601 datetime; omit for no expiry. */
650
- expiresAt: z13.iso.datetime({ offset: true }).optional()
857
+ expiresAt: z15.iso.datetime({ offset: true }).optional()
651
858
  });
652
859
  var createTokenResponseSchema = apiTokenSchema.extend({
653
- token: z13.string()
860
+ token: z15.string()
654
861
  });
655
862
  var listTokensResponseSchema = listResponseSchema(apiTokenSchema);
656
863
 
864
+ // src/commands/apply.ts
865
+ import { z as z16 } from "zod";
866
+
657
867
  // src/version.ts
658
868
  import { createRequire } from "module";
659
869
  var CLI_VERSION = createRequire(import.meta.url)("../package.json").version;
@@ -979,6 +1189,34 @@ function cell(value) {
979
1189
  }
980
1190
 
981
1191
  // src/commands/apply.ts
1192
+ var EXAMPLE_SPEC = {
1193
+ version: 1,
1194
+ expand: true,
1195
+ experiment: "my-experiment",
1196
+ defaults: { agents: ["CLAUDE_CODE"], samplesPerCycle: 3 },
1197
+ prompts: [
1198
+ {
1199
+ key: "add-healthcheck",
1200
+ text: "Add a /health endpoint that returns 200 OK.",
1201
+ scenario: "GREENFIELD"
1202
+ },
1203
+ {
1204
+ key: "migrate-to-vitest",
1205
+ text: "Migrate the test suite from Jest to Vitest.",
1206
+ scenario: "MIGRATION",
1207
+ schedules: [
1208
+ {
1209
+ repoUrl: "https://github.com/acme/api",
1210
+ repoRef: "main",
1211
+ // Optional: pin a specific model id. Must be one the schedule's
1212
+ // agent(s) can actually serve, or the run falls back to the agent
1213
+ // default. Omit (or use null) to always use the agent default.
1214
+ model: "claude-opus-4-8"
1215
+ }
1216
+ ]
1217
+ }
1218
+ ]
1219
+ };
982
1220
  function readSpec(path) {
983
1221
  let raw;
984
1222
  try {
@@ -998,10 +1236,18 @@ function readSpec(path) {
998
1236
  `spec is not valid JSON: ${e instanceof Error ? e.message : String(e)}`
999
1237
  );
1000
1238
  }
1001
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
1002
- throw new CliError("invalid_request", "spec must be a JSON object");
1239
+ const result = batteries_exports.batterySpecSchema.safeParse(parsed);
1240
+ if (!result.success) {
1241
+ const details = result.error.issues.map((i) => ` ${i.path.join(".") || "(spec)"}: ${i.message}`).join("\n");
1242
+ throw new CliError(
1243
+ "invalid_request",
1244
+ `not a valid battery spec:
1245
+ ${details}
1246
+
1247
+ Run \`gauge apply --schema\` for the full schema, or \`gauge apply --example\` for a starter.`
1248
+ );
1003
1249
  }
1004
- return parsed;
1250
+ return result.data;
1005
1251
  }
1006
1252
  function resolveApplyOrg(command, spec) {
1007
1253
  const { org } = command.optsWithGlobals();
@@ -1061,8 +1307,27 @@ function printApplied(res) {
1061
1307
  }
1062
1308
  }
1063
1309
  function register(program2) {
1064
- program2.command("apply").description("Apply a declarative battery spec (see specs/battery.md)").requiredOption("-f, --file <path>", "battery spec JSON file").option("--dry-run", "print the plan without applying").action(
1310
+ program2.command("apply").description(
1311
+ "Apply a declarative battery spec. Use --example to scaffold one, or --schema to print its JSON Schema."
1312
+ ).option("-f, --file <path>", "battery spec JSON file").option("--dry-run", "print the plan without applying").option("--schema", "print the battery spec JSON Schema and exit").option("--example", "print a minimal example battery spec and exit").action(
1065
1313
  async (opts, command) => {
1314
+ if (opts.schema) {
1315
+ printJson(z16.toJSONSchema(batteries_exports.batterySpecSchema));
1316
+ return;
1317
+ }
1318
+ if (opts.example) {
1319
+ printJson(EXAMPLE_SPEC);
1320
+ console.error(
1321
+ "\n# Save to battery.json, edit, then: gauge apply -f battery.json"
1322
+ );
1323
+ return;
1324
+ }
1325
+ if (!opts.file) {
1326
+ throw new CliError(
1327
+ "usage",
1328
+ "Pass -f <path> with a battery spec (or --example to scaffold one, --schema to see the schema)."
1329
+ );
1330
+ }
1066
1331
  const spec = readSpec(opts.file);
1067
1332
  const org = resolveApplyOrg(command, spec);
1068
1333
  const output = resolveOutput(command);
@@ -2110,10 +2375,239 @@ function register9(program2) {
2110
2375
  );
2111
2376
  }
2112
2377
 
2378
+ // src/commands/query.ts
2379
+ var query_exports2 = {};
2380
+ __export(query_exports2, {
2381
+ register: () => register10
2382
+ });
2383
+ var collect3 = (value, prev = []) => [
2384
+ ...prev,
2385
+ value
2386
+ ];
2387
+ var csv = (raw) => raw.split(",").map((s) => s.trim()).filter(Boolean);
2388
+ function parseWhere(expr) {
2389
+ const inMatch = expr.match(/^\s*(\w+)\s+(in|contains)\s+(.*)$/i);
2390
+ if (inMatch) {
2391
+ const [, dimension2, opRaw, rest2] = inMatch;
2392
+ const op = opRaw.toLowerCase();
2393
+ if (op === "in") {
2394
+ return { dimension: dimension2, op: "in", value: csv(rest2) };
2395
+ }
2396
+ return { dimension: dimension2, op: "contains", value: rest2.trim() };
2397
+ }
2398
+ const opMatch = expr.match(/^\s*(\w+)\s*(!=|>=|<=|=|>|<)\s*(.*)$/);
2399
+ if (!opMatch) {
2400
+ throw new CliError(
2401
+ "usage",
2402
+ `Could not parse --where "${expr}". Use e.g. "action=install", "ecosystem in npm,pypi", or "name contains supa".`
2403
+ );
2404
+ }
2405
+ const [, dimension, sym, rest] = opMatch;
2406
+ const opFor = {
2407
+ "=": "eq",
2408
+ "!=": "neq",
2409
+ ">": "gt",
2410
+ ">=": "gte",
2411
+ "<": "lt",
2412
+ "<=": "lte"
2413
+ };
2414
+ return { dimension, op: opFor[sym], value: rest.trim() };
2415
+ }
2416
+ function parseOrderBy(raw) {
2417
+ const [key, dir] = raw.split(":");
2418
+ return { key: key.trim(), dir: dir?.trim() === "asc" ? "asc" : "desc" };
2419
+ }
2420
+ async function readStdin2() {
2421
+ const chunks = [];
2422
+ for await (const chunk of process.stdin) chunks.push(chunk);
2423
+ return Buffer.concat(chunks).toString("utf8");
2424
+ }
2425
+ async function buildSpec(opts) {
2426
+ let spec = { metrics: [] };
2427
+ if (opts.json) {
2428
+ const raw = opts.json === "-" ? await readStdin2() : opts.json;
2429
+ try {
2430
+ spec = JSON.parse(raw);
2431
+ } catch (e) {
2432
+ throw new CliError(
2433
+ "usage",
2434
+ `--json is not valid JSON: ${e.message}`
2435
+ );
2436
+ }
2437
+ }
2438
+ if (opts.dataset) spec.dataset = opts.dataset;
2439
+ if (opts.dimensions !== void 0) spec.dimensions = csv(opts.dimensions);
2440
+ if (opts.metrics !== void 0) spec.metrics = csv(opts.metrics);
2441
+ if (opts.where?.length) spec.where = opts.where.map(parseWhere);
2442
+ if (opts.orderBy?.length) spec.orderBy = opts.orderBy.map(parseOrderBy);
2443
+ if (opts.limit !== void 0) spec.limit = Number(opts.limit);
2444
+ if (opts.granularity)
2445
+ spec.granularity = opts.granularity;
2446
+ if (opts.explain) spec.explain = true;
2447
+ const date = {
2448
+ ...spec.dateRange ?? {}
2449
+ };
2450
+ if (opts.since) {
2451
+ date.since = opts.since;
2452
+ delete date.lastDays;
2453
+ } else if (opts.lastDays) {
2454
+ date.lastDays = Number(opts.lastDays);
2455
+ delete date.since;
2456
+ }
2457
+ if (opts.until) date.until = opts.until;
2458
+ if (Object.keys(date).length) spec.dateRange = date;
2459
+ if (opts.branded && opts.unbranded) {
2460
+ throw new CliError("usage", "Pass at most one of --branded / --unbranded.");
2461
+ }
2462
+ const filters = {
2463
+ ...spec.filters ?? {}
2464
+ };
2465
+ if (opts.prompt) filters.prompt = opts.prompt;
2466
+ if (opts.topic) filters.topic = csv(opts.topic);
2467
+ if (opts.tag) filters.tag = csv(opts.tag);
2468
+ if (opts.repo) filters.repo = csv(opts.repo);
2469
+ if (opts.language) filters.language = csv(opts.language);
2470
+ if (opts.framework) filters.framework = csv(opts.framework);
2471
+ if (opts.size) filters.size = csv(opts.size);
2472
+ if (opts.agent) filters.agent = csv(opts.agent);
2473
+ if (opts.model) filters.model = csv(opts.model);
2474
+ if (opts.scenario) filters.scenario = csv(opts.scenario);
2475
+ if (opts.experiment) filters.experiment = csv(opts.experiment);
2476
+ if (opts.branded) filters.branded = true;
2477
+ if (opts.unbranded) filters.branded = false;
2478
+ if (Object.keys(filters).length) spec.filters = filters;
2479
+ if (!spec.metrics || spec.metrics.length === 0) {
2480
+ throw new CliError(
2481
+ "usage",
2482
+ "At least one metric is required. Pass --metrics <a,b> (or a `metrics` array in --json). See `gauge query fields --dataset <name>`."
2483
+ );
2484
+ }
2485
+ return spec;
2486
+ }
2487
+ var pct = (n) => `${(n * 100).toFixed(1)}%`;
2488
+ function noteFreshness(f) {
2489
+ if (!f.available) {
2490
+ console.error(
2491
+ "warning: analytics store is temporarily unavailable; results may be incomplete."
2492
+ );
2493
+ } else if (f.pending > 0) {
2494
+ console.error(
2495
+ `note: ${f.pending} recent run(s) still ingesting; results may not reflect them yet.`
2496
+ );
2497
+ }
2498
+ }
2499
+ async function runQuery(command, opts) {
2500
+ const org = resolveOrg(command);
2501
+ const output = resolveOutput(command);
2502
+ const spec = await buildSpec(opts);
2503
+ const res = await createClient().post(
2504
+ `/api/v1/orgs/${encodeURIComponent(org)}/query`,
2505
+ spec
2506
+ );
2507
+ if (output === "json") {
2508
+ printJson(res);
2509
+ return;
2510
+ }
2511
+ if (res.sql) console.error(`
2512
+ ${res.sql}
2513
+ `);
2514
+ const rateKeys = new Set(
2515
+ res.columns.filter((c) => c.kind === "metric" && c.key.endsWith("_rate")).map((c) => c.key)
2516
+ );
2517
+ const rows = res.rows.map((row) => {
2518
+ const out = {};
2519
+ for (const col of res.columns) {
2520
+ const v = row[col.key];
2521
+ out[col.key] = rateKeys.has(col.key) && typeof v === "number" ? pct(v) : v;
2522
+ }
2523
+ return out;
2524
+ });
2525
+ printItems(
2526
+ rows,
2527
+ "table",
2528
+ res.columns.map((c) => ({ key: c.key }))
2529
+ );
2530
+ noteFreshness(res.freshness);
2531
+ }
2532
+ async function showMetadata(command, mode, dataset) {
2533
+ const org = resolveOrg(command);
2534
+ const output = resolveOutput(command);
2535
+ const meta = await createClient().get(
2536
+ `/api/v1/orgs/${encodeURIComponent(org)}/query/metadata`
2537
+ );
2538
+ if (mode === "datasets") {
2539
+ if (output === "json")
2540
+ return printJson(
2541
+ meta.datasets.map((d) => ({ name: d.name, grain: d.grain }))
2542
+ );
2543
+ printItems(
2544
+ meta.datasets.map((d) => ({ dataset: d.name, grain: d.grain })),
2545
+ "table"
2546
+ );
2547
+ return;
2548
+ }
2549
+ const ds = meta.datasets.find((d) => d.name === dataset);
2550
+ if (!ds) {
2551
+ throw new CliError(
2552
+ "usage",
2553
+ `Unknown dataset "${dataset}". Valid: ${meta.datasets.map((d) => d.name).join(", ")}.`
2554
+ );
2555
+ }
2556
+ if (output === "json") return printJson(ds);
2557
+ const rows = [
2558
+ ...ds.dimensions.map((f) => ({
2559
+ field: f.name,
2560
+ kind: "dimension",
2561
+ type: f.type,
2562
+ about: f.description ?? ""
2563
+ })),
2564
+ ...ds.metrics.map((f) => ({
2565
+ field: f.name,
2566
+ kind: "metric",
2567
+ type: f.type,
2568
+ about: f.description ?? ""
2569
+ }))
2570
+ ];
2571
+ console.error(`dataset: ${ds.name} \u2014 ${ds.grain}`);
2572
+ printItems(rows, "table");
2573
+ }
2574
+ function register10(program2) {
2575
+ const group = program2.command("query").description(
2576
+ "Flexible reports over your event warehouse (run a report, or discover the catalog)"
2577
+ );
2578
+ group.command("run", { isDefault: true }).description("Run a report (default command)").option(
2579
+ "--json <spec>",
2580
+ "full query spec as JSON (or '-' to read stdin); flags override its keys"
2581
+ ).option(
2582
+ "--dataset <name>",
2583
+ "runs | installs | mentions | web | network | files | tokens (default runs)"
2584
+ ).option("-d, --dimensions <names>", "comma-separated GROUP BY dimensions").option("-m, --metrics <names>", "comma-separated metrics (at least one)").option(
2585
+ "--where <expr>",
2586
+ 'predicate, e.g. "action=install" (repeatable)',
2587
+ collect3
2588
+ ).option("--since <val>", "date range start \u2014 ISO date or window (30d, 24h)").option("--until <val>", "date range end \u2014 ISO date or window").option("--last-days <n>", "shorthand for --since <n> days ago").option(
2589
+ "--order-by <key:dir>",
2590
+ "sort by a selected key, e.g. installs:desc (repeatable)",
2591
+ collect3
2592
+ ).option("--limit <n>", "max rows (default 50, max 1000)").option(
2593
+ "--granularity <g>",
2594
+ "date bucket: day | week | month (default day)"
2595
+ ).option("--explain", "print the compiled SQL to stderr").option("--prompt <id>", "filter to a single prompt").option("--topic <ids>", "comma-separated topic ids").option("--tag <ids>", "comma-separated tag ids").option("--repo <urls>", "comma-separated base repo urls").option("--language <langs>", "comma-separated repo languages").option("--framework <names>", "comma-separated repo frameworks").option("--size <buckets>", "comma-separated codebase-size buckets").option("--agent <names>", "comma-separated agent names").option("--model <models>", "comma-separated models").option(
2596
+ "--scenario <types>",
2597
+ "comma-separated scenario types (greenfield|migration)"
2598
+ ).option("--experiment <labels>", "comma-separated experiment labels").option("--branded", "only branded prompts").option("--unbranded", "only non-branded prompts").action((opts, command) => runQuery(command, opts));
2599
+ group.command("datasets").description("List the datasets you can query").action(
2600
+ (_opts, command) => showMetadata(command, "datasets")
2601
+ );
2602
+ group.command("fields").description("List the dimensions and metrics for a dataset").requiredOption("--dataset <name>", "dataset to describe").action(
2603
+ (opts, command) => showMetadata(command, "fields", opts.dataset)
2604
+ );
2605
+ }
2606
+
2113
2607
  // src/commands/repos.ts
2114
2608
  var repos_exports2 = {};
2115
2609
  __export(repos_exports2, {
2116
- register: () => register10
2610
+ register: () => register11
2117
2611
  });
2118
2612
  function reposPath(org) {
2119
2613
  return `/api/v1/orgs/${encodeURIComponent(org)}/repos`;
@@ -2136,7 +2630,7 @@ function toRow3(repo) {
2136
2630
  function syncWarning(repo) {
2137
2631
  return `warning: GitHub metadata sync failed; retry with \`gauge repos resync ${repo.url}\``;
2138
2632
  }
2139
- function register10(program2) {
2633
+ function register11(program2) {
2140
2634
  const repos = program2.command("repos").description("Manage repositories");
2141
2635
  repos.command("list").description("List repositories (yours + read-only Gauge-provided ones)").action(async (_opts, command) => {
2142
2636
  const org = resolveOrg(command);
@@ -2200,7 +2694,7 @@ function register10(program2) {
2200
2694
  // src/commands/runs.ts
2201
2695
  var runs_exports2 = {};
2202
2696
  __export(runs_exports2, {
2203
- register: () => register11
2697
+ register: () => register12
2204
2698
  });
2205
2699
  function runPath(id) {
2206
2700
  return `/api/v1/runs/${encodeURIComponent(id)}`;
@@ -2378,7 +2872,7 @@ async function streamRun(id, json, opts) {
2378
2872
  if (drainTimer) clearTimeout(drainTimer);
2379
2873
  }
2380
2874
  }
2381
- function register11(program2) {
2875
+ function register12(program2) {
2382
2876
  const runs = program2.command("runs").description("Inspect and manage runs");
2383
2877
  runs.command("list").description("List runs (newest first)").option("--status <status>", "filter by status, e.g. running,queued").option("--batch <id>", "filter by batch").option("--prompt <id>", "filter by prompt").option("--experiment <experiment>", "filter by experiment label").option("--since <window>", "e.g. 24h, 7d, or an ISO date").option("--limit <n>", "page size (1-200)", "50").option("--cursor <cursor>", "resume from a previous page's nextCursor").action(
2384
2878
  async (opts, command) => {
@@ -2440,6 +2934,20 @@ function register11(program2) {
2440
2934
  const diff = await createClient().get(`${runPath(id)}/diff`);
2441
2935
  process.stdout.write(diff);
2442
2936
  });
2937
+ runs.command("fork <id>").description("Fork a finished run from its latest conversation checkpoint").requiredOption("--prompt <text>", "continuation prompt for the child run").action(async (id, opts, command) => {
2938
+ const result = await createClient().post(
2939
+ `${runPath(id)}/fork`,
2940
+ { prompt: opts.prompt }
2941
+ );
2942
+ if (resolveOutput(command) === "json") {
2943
+ printJson(result);
2944
+ return;
2945
+ }
2946
+ console.log(
2947
+ `Forked run ${result.runId} from ${result.parentRunId} at turn ${result.turn}`
2948
+ );
2949
+ console.error(`Watch it with: gauge runs watch ${result.runId}`);
2950
+ });
2443
2951
  runs.command("cancel <id>").description("Request cancellation of a run").action(async (id, _opts, command) => {
2444
2952
  const result = await createClient().post(
2445
2953
  `${runPath(id)}/cancel`
@@ -2458,7 +2966,7 @@ function register11(program2) {
2458
2966
  // src/commands/schedules.ts
2459
2967
  var schedules_exports2 = {};
2460
2968
  __export(schedules_exports2, {
2461
- register: () => register12
2969
+ register: () => register13
2462
2970
  });
2463
2971
  var CADENCE_CHOICES = [
2464
2972
  "none",
@@ -2494,7 +3002,7 @@ function toRow5(s) {
2494
3002
  experiment: s.experiment ?? ""
2495
3003
  };
2496
3004
  }
2497
- function register12(program2) {
3005
+ function register13(program2) {
2498
3006
  const group = program2.command("schedules").description("Manage prompt schedules");
2499
3007
  group.command("list").description("List schedules for a prompt").requiredOption("--prompt <id>", "prompt id").action(async (opts, cmd) => {
2500
3008
  const org = resolveOrg(cmd);
@@ -2562,15 +3070,131 @@ function register12(program2) {
2562
3070
  });
2563
3071
  }
2564
3072
 
3073
+ // src/commands/stats.ts
3074
+ var stats_exports2 = {};
3075
+ __export(stats_exports2, {
3076
+ register: () => register14
3077
+ });
3078
+ function addFilterOptions(cmd) {
3079
+ return cmd.option("--prompt <id>", "filter to a single prompt").option("--topic <ids>", "comma-separated topic ids").option("--tag <ids>", "comma-separated tag ids").option("--repo <urls>", "comma-separated base repo urls").option("--language <langs>", "comma-separated repo languages").option("--framework <names>", "comma-separated repo frameworks").option("--size <buckets>", "comma-separated codebase-size buckets").option("--branded", "only branded prompts").option("--unbranded", "only non-branded prompts").option("--limit <n>", "max rows (default 50)").option("--full", "return all rows (up to 1000)");
3080
+ }
3081
+ function filterQuery(opts) {
3082
+ if (opts.branded && opts.unbranded) {
3083
+ throw new CliError("usage", "Pass at most one of --branded / --unbranded.");
3084
+ }
3085
+ return {
3086
+ prompt: opts.prompt,
3087
+ topic: opts.topic,
3088
+ tag: opts.tag,
3089
+ repo: opts.repo,
3090
+ language: opts.language,
3091
+ framework: opts.framework,
3092
+ size: opts.size,
3093
+ branded: opts.branded ? "true" : opts.unbranded ? "false" : void 0,
3094
+ limit: opts.full ? "1000" : opts.limit
3095
+ };
3096
+ }
3097
+ var pct2 = (rate) => `${(rate * 100).toFixed(1)}%`;
3098
+ var delta = (d) => d === null || d === 0 ? "\u2014" : d > 0 ? `+${d}` : String(d);
3099
+ function noteFreshness2(f) {
3100
+ if (!f.available) {
3101
+ console.error(
3102
+ "warning: analytics store is temporarily unavailable; results may be incomplete."
3103
+ );
3104
+ } else if (f.pending > 0) {
3105
+ console.error(
3106
+ `note: ${f.pending} recent run(s) still ingesting; results may not reflect them yet.`
3107
+ );
3108
+ }
3109
+ }
3110
+ async function runStats(command, resource, opts, toRow6) {
3111
+ const org = resolveOrg(command);
3112
+ const output = resolveOutput(command);
3113
+ const res = await createClient().get(
3114
+ `/api/v1/orgs/${encodeURIComponent(org)}/stats/${resource}`,
3115
+ filterQuery(opts)
3116
+ );
3117
+ if (output === "json") {
3118
+ printJson(res);
3119
+ return;
3120
+ }
3121
+ printItems(res.items.map(toRow6), "table");
3122
+ noteFreshness2(res.freshness);
3123
+ }
3124
+ var rankingRow = (r) => ({
3125
+ rank: r.rank,
3126
+ brand: r.brandName,
3127
+ kind: r.kind,
3128
+ installs: r.installs,
3129
+ "install%": pct2(r.installRate),
3130
+ "mention%": pct2(r.mentionRate),
3131
+ delta: delta(r.deltaRank)
3132
+ });
3133
+ var packageRow = (r) => ({
3134
+ package: r.name,
3135
+ ecosystem: r.ecosystem,
3136
+ brand: r.brandName,
3137
+ kind: r.kind,
3138
+ installs: r.installs,
3139
+ rate: pct2(r.rate)
3140
+ });
3141
+ var brandRow = (r) => ({
3142
+ brand: r.brandName,
3143
+ kind: r.kind,
3144
+ installs: r.installs,
3145
+ rate: pct2(r.rate)
3146
+ });
3147
+ var funnelRow = (r) => ({
3148
+ brand: r.brandName,
3149
+ kind: r.kind,
3150
+ "mention%": pct2(r.mentionRate),
3151
+ "install%": pct2(r.installRate)
3152
+ });
3153
+ var domainRow = (r) => ({
3154
+ domain: r.domain,
3155
+ brand: r.brandName,
3156
+ runs: r.runs,
3157
+ rate: pct2(r.rate),
3158
+ requests: r.requests
3159
+ });
3160
+ function register14(program2) {
3161
+ const group = program2.command("stats").description("Read-only analytics over your runs");
3162
+ addFilterOptions(
3163
+ group.command("rankings").description("Brands ranked by install rate")
3164
+ ).action(
3165
+ (opts, command) => runStats(command, "rankings", opts, rankingRow)
3166
+ );
3167
+ addFilterOptions(
3168
+ group.command("installs").description("Package install rates (share of voice)")
3169
+ ).action(
3170
+ (opts, command) => runStats(command, "installs", opts, packageRow)
3171
+ );
3172
+ addFilterOptions(
3173
+ group.command("brands").description("Per-brand (company-level) install rates")
3174
+ ).action(
3175
+ (opts, command) => runStats(command, "brands", opts, brandRow)
3176
+ );
3177
+ addFilterOptions(
3178
+ group.command("funnel").description("Per-brand mention rate beside install rate")
3179
+ ).action(
3180
+ (opts, command) => runStats(command, "funnel", opts, funnelRow)
3181
+ );
3182
+ addFilterOptions(
3183
+ group.command("domains").description("Outbound fetch rates by registrable domain")
3184
+ ).action(
3185
+ (opts, command) => runStats(command, "domains", opts, domainRow)
3186
+ );
3187
+ }
3188
+
2565
3189
  // src/commands/tags.ts
2566
3190
  var tags_exports2 = {};
2567
3191
  __export(tags_exports2, {
2568
- register: () => register13
3192
+ register: () => register15
2569
3193
  });
2570
3194
  function tagsPath(org) {
2571
3195
  return `/api/v1/orgs/${encodeURIComponent(org)}/tags`;
2572
3196
  }
2573
- function register13(program2) {
3197
+ function register15(program2) {
2574
3198
  const group = program2.command("tags").description("Manage org tags");
2575
3199
  group.command("list").description("List tags").action(async (_opts, cmd) => {
2576
3200
  const org = resolveOrg(cmd);
@@ -2613,12 +3237,12 @@ function register13(program2) {
2613
3237
  // src/commands/topics.ts
2614
3238
  var topics_exports2 = {};
2615
3239
  __export(topics_exports2, {
2616
- register: () => register14
3240
+ register: () => register16
2617
3241
  });
2618
3242
  function topicsPath(org) {
2619
3243
  return `/api/v1/orgs/${encodeURIComponent(org)}/topics`;
2620
3244
  }
2621
- function register14(program2) {
3245
+ function register16(program2) {
2622
3246
  const group = program2.command("topics").description("Manage org topics");
2623
3247
  group.command("list").description("List topics").action(async (_opts, cmd) => {
2624
3248
  const org = resolveOrg(cmd);
@@ -2639,9 +3263,9 @@ function register14(program2) {
2639
3263
  // src/commands/usage.ts
2640
3264
  var usage_exports = {};
2641
3265
  __export(usage_exports, {
2642
- register: () => register15
3266
+ register: () => register17
2643
3267
  });
2644
- function register15(program2) {
3268
+ function register17(program2) {
2645
3269
  program2.command("usage").description("List credit ledger entries").option("--since <window>", 'e.g. "30d", "24h", or an ISO date').option("--limit <n>", "page size (1-200)", parseLimit, 50).option("--cursor <cursor>", "resume from a previous page's nextCursor").action(
2646
3270
  async (opts, cmd) => {
2647
3271
  const org = resolveOrg(cmd);
@@ -2710,6 +3334,8 @@ for (const group of [
2710
3334
  keys_exports2,
2711
3335
  billing_exports2,
2712
3336
  usage_exports,
3337
+ stats_exports2,
3338
+ query_exports2,
2713
3339
  config_exports
2714
3340
  ]) {
2715
3341
  group.register(program);
@@ -2722,7 +3348,11 @@ try {
2722
3348
  process.exit(error.exitCode === 0 ? 0 : 2);
2723
3349
  }
2724
3350
  if (error instanceof CliError) {
2725
- process.stderr.write(`error: ${error.message}
3351
+ let message2 = error.message;
3352
+ if (error.code === "not_found" && /organization/i.test(message2) && !program.opts().org) {
3353
+ message2 += "\nThat is your configured default organization. Run `gauge orgs list` to see yours, then `gauge orgs use <org>` to update it.";
3354
+ }
3355
+ process.stderr.write(`error: ${message2}
2726
3356
  `);
2727
3357
  process.exit(error.exitCode);
2728
3358
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withgauge/cli",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Gauge customer CLI — prompts, repos, runs & org settings over the Gauge API",
5
5
  "private": false,
6
6
  "author": "Gauge <support@withgauge.com> (https://withgauge.com)",
@@ -11,7 +11,7 @@
11
11
  "access": "public"
12
12
  },
13
13
  "bin": {
14
- "gauge": "./dist/index.js"
14
+ "gauge": "dist/index.js"
15
15
  },
16
16
  "files": [
17
17
  "dist"