@neta-art/cohub-cli 3.6.3 → 3.7.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 CHANGED
@@ -276,6 +276,7 @@ cohub profile update --username <username>
276
276
  cohub spaces update <spaceId> --slug <space-slug>
277
277
  cohub -s <spaceId> works ls --json
278
278
  cohub works get <workId|url|username/space/work> --json
279
+ cohub works stats <workId|url|username/space/work>
279
280
  cohub works download <workId|url|username/space/work> --output <path>
280
281
  cohub -s <spaceId> works publish demo --file dist/index.html
281
282
  cohub -s <spaceId> works publish site --dir dist
@@ -291,7 +292,7 @@ Resolve a published Work by public identity:
291
292
  cohub works resolve <workSlug> --owner <username> --space-slug <spaceSlug>
292
293
  ```
293
294
 
294
- Use `--json` for machine-readable output. `works get` and `works download` also accept `cohub://works/<username>/<space>/<work>` mention URIs. Download restores newly published file and directory artifacts directly from the CDN with checksum verification. HTML files with companion assets are restored as directory bundles; Board and port Works are not downloadable. The resolve command remains available for explicit slug-based lookup.
295
+ Use `--json` for machine-readable output. `works get`, `works stats`, and `works download` also accept `cohub://works/<username>/<space>/<work>` mention URIs. `works stats` reports total, 24-hour, 7-day, and 30-day views with a source breakdown. Download restores newly published file and directory artifacts directly from the CDN with checksum verification. HTML files with companion assets are restored as directory bundles; Board and port Works are not downloadable. The resolve command remains available for explicit slug-based lookup.
295
296
 
296
297
  Realtime rooms use a published Work's runtime identity, so they are available
297
298
  through `client.work.realtime` in the SDK rather than as CLI commands.
@@ -1,2 +1,4 @@
1
+ import { type CohubHttpClient, type WorkViewStatsResponse } from "@neta-art/cohub";
1
2
  import type { Command } from "commander";
3
+ export declare function getWorkStatsByRef(client: CohubHttpClient, work: string): Promise<WorkViewStatsResponse>;
2
4
  export declare function registerWorks(program: Command): void;
@@ -3,7 +3,7 @@ import { createClient } from "../client.js";
3
3
  import { error, handleHttp, json as outJson, jsonRequested, ok, table } from "../output.js";
4
4
  import { resolveSpace } from "../space.js";
5
5
  import { downloadWork } from "../work-download.js";
6
- import { getWorkByRef } from "../work-ref.js";
6
+ import { getWorkByRef, parseWorkRef } from "../work-ref.js";
7
7
  import { registerWorkCommerce } from "./work-commerce.js";
8
8
  const WORK_STATUSES = ["published", "disabled"];
9
9
  const WORK_VISIBILITIES = ["public", "space"];
@@ -87,6 +87,28 @@ function printWorkUrls(result) {
87
87
  if (lines.length)
88
88
  console.log(`\n${lines.join("\n")}`);
89
89
  }
90
+ function printWorkStats(stats) {
91
+ table([stats.summary], [
92
+ { key: "totalViews", label: "Total" },
93
+ { key: "views24h", label: "24h" },
94
+ { key: "views7d", label: "7d" },
95
+ { key: "views30d", label: "30d" },
96
+ ]);
97
+ if (stats.sources.length) {
98
+ console.log("");
99
+ table(stats.sources, [
100
+ { key: "source", label: "Source" },
101
+ { key: "views", label: "Views" },
102
+ ]);
103
+ }
104
+ }
105
+ export async function getWorkStatsByRef(client, work) {
106
+ const ref = parseWorkRef(work);
107
+ if ("id" in ref)
108
+ return client.works.getStats(ref.id);
109
+ const detail = await getWorkByRef(client, work);
110
+ return client.works.getStats(detail.work.id);
111
+ }
90
112
  async function confirmDelete(opts) {
91
113
  if (opts.yes)
92
114
  return;
@@ -161,6 +183,22 @@ export function registerWorks(program) {
161
183
  handleHttp(e);
162
184
  }
163
185
  });
186
+ worksCmd
187
+ .command("stats <work>")
188
+ .description("Show view statistics by id, URL, mention URI, or username/space/work")
189
+ .option("--json", "Output as JSON")
190
+ .action(async (work, opts) => {
191
+ const client = createClient();
192
+ try {
193
+ const result = await getWorkStatsByRef(client, work);
194
+ if (jsonRequested(opts))
195
+ return outJson(result);
196
+ printWorkStats(result);
197
+ }
198
+ catch (e) {
199
+ handleHttp(e);
200
+ }
201
+ });
164
202
  worksCmd
165
203
  .command("download <work>")
166
204
  .description("Download a published file or directory Work")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "3.6.3",
3
+ "version": "3.7.0",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -15,11 +15,11 @@
15
15
  "NOTICE"
16
16
  ],
17
17
  "dependencies": {
18
- "@neta-art/generation": "^0.1.18",
18
+ "@neta-art/generation": "^0.1.19",
19
19
  "commander": "^15.0.0",
20
20
  "pixi.js": "^8.19.0",
21
21
  "sharp": "^0.35.3",
22
- "@neta-art/cohub": "5.1.1"
22
+ "@neta-art/cohub": "5.2.0"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"