@calo-design/cli 0.4.5 → 0.4.6

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 (2) hide show
  1. package/bin/cli.js +23 -0
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -659,6 +659,28 @@ async function cmdFeed() {
659
659
  for (const e of data.events) log(`${c.dim(e.ts)} ${e.email} ${c.b(e.action)} ${e.target || ""}`);
660
660
  }
661
661
 
662
+ // Per-prototype analytics (Design Kitchen reads this via `--json`). Same session reuse as
663
+ // the feed; the broker holds the Clarity token and does the caching — this is a dumb pipe.
664
+ async function cmdInsights() {
665
+ const session = await ensureSession();
666
+ let res;
667
+ try {
668
+ res = await fetch(`${BROKER}/v1/clarity/insights`, {
669
+ headers: { authorization: `Bearer ${session}` },
670
+ signal: AbortSignal.timeout(20000),
671
+ });
672
+ } catch (e) {
673
+ throw new Error(`can't reach the Calo broker at ${BROKER} (${e.message})`);
674
+ }
675
+ const text = await res.text();
676
+ if (!res.ok) throw new Error(`insights failed (${res.status}): ${text.slice(0, 200)}`);
677
+ if (has("--json")) { process.stdout.write("\n" + text + "\n"); return; }
678
+ const data = JSON.parse(text);
679
+ const protos = Object.values(data.prototypes || {});
680
+ log(`${data.totals?.sessions ?? 0} sessions across ${protos.length} prototype(s) · last ${data.windowDays} days`);
681
+ for (const p of protos) log(` ${c.b(p.slug || p.host)} ${p.sessions} sessions · ${p.activeSeconds}s active`);
682
+ }
683
+
662
684
  // Serve the component gallery (the @calo/design-system showroom) locally, rendered LIVE from
663
685
  // the shared runtime — so `calo-design update` keeps it current (no rebuild/redeploy). Design
664
686
  // Kitchen auto-starts this; it also works standalone in a terminal. Runs Metro in the
@@ -725,6 +747,7 @@ function help() {
725
747
  else if (cmd === "push") await cmdPush(args.slice(1));
726
748
  else if (cmd === "share") await cmdShare(args.slice(1));
727
749
  else if (cmd === "feed") await cmdFeed();
750
+ else if (cmd === "insights") await cmdInsights();
728
751
  else if (cmd === "whoami") await cmdWhoami();
729
752
  else if (cmd === "gallery") await cmdGallery();
730
753
  else help();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calo-design/cli",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "One-line setup for Calo design tooling: logs in with your Calo email and installs the calo-design skill + design-system packages. No GitHub account needed.",
5
5
  "bin": {
6
6
  "calo-design": "bin/cli.js"