@hypersocial/decks-cli 0.9.19 → 0.9.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypersocial/decks-cli",
3
- "version": "0.9.19",
3
+ "version": "0.9.20",
4
4
  "description": "Command-line client for Hypersocial Decks live analytics and share management.",
5
5
  "type": "module",
6
6
  "main": "./src/commands.mjs",
@@ -2,7 +2,7 @@
2
2
  name: hyperdecks
3
3
  description: Use when asked to make, narrate, check or ship a deck ("make me a narrated deck", "turn this into a deck and send it"), or when working with Hypersocial Decks, Hyperdecks CLI, production deck analytics, recipient share links, deck activity, MCP deck tools, or real-world/customer-facing deck checks. Prefer production for real activity and analytics; use development only for local implementation/testing when explicitly requested.
4
4
  metadata:
5
- version: "0.9.19"
5
+ version: "0.9.20"
6
6
  ---
7
7
 
8
8
  # Hyperdecks
@@ -1005,6 +1005,12 @@ rebuild's list on 2026-11-05 produced four.
1005
1005
  live changes, state the action and target clearly before executing when user
1006
1006
  intent is ambiguous.
1007
1007
  - Avoid printing full share tokens unless the user needs the exact URL/token.
1008
+ - Tag the decks you make so the owner can find them: `hyperdecks deck tag <slug>
1009
+ add <tag...>` / `tag_deck { slug, add, remove }` (lowercase a-z 0-9 -, 1–32
1010
+ characters, spaces become -, at most 10 a deck; `remove` takes them off).
1011
+ `deck list --tag <tag>` / `list_decks { tag }` lists one tag's decks, and
1012
+ `deck new … --tag <tag,...>` tags at creation. Tags are the owner's own
1013
+ labels: recipients never see them.
1008
1014
  - To retire a deck ("archive it", "put it away", a superseded draft), archive it:
1009
1015
  `hyperdecks deck archive <slug>` / `archive_deck`. It is reversible
1010
1016
  (`deck unarchive` / `unarchive_deck` puts back the status it had) and deletes
@@ -112,7 +112,9 @@ makes the hello deck; continue from step 5 below.
112
112
  gates; owners can turn it off with `set_deck_view { slug, aiReadable: false }`.
113
113
  `set_share_notify` to mute a link's "opened" alerts;
114
114
  `set_recipient_archived` to tidy the activity feed; `credits` for the
115
- balance. `archive_deck` sets a deck aside reversibly (its links pause and
115
+ balance. `tag_deck { slug, add, remove }` labels a deck for its owner
116
+ (investors, fizz-fm…; recipients never see tags): tag the decks you make,
117
+ and `list_decks { tag }` lists one tag's decks. `archive_deck` sets a deck aside reversibly (its links pause and
116
118
  exports are refused while archived; nothing is deleted; `unarchive_deck` brings it back as it was): use it when
117
119
  someone wants a deck archived or out of the way. `remove_deck` permanently
118
120
  deletes a deck and breaks every link to it: only when they ask to delete,
package/src/commands.mjs CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  import { fetchVersionInfo, updatePreflight } from "./update.mjs";
18
18
  import { refreshSkillCopies } from "./skillFreshness.mjs";
19
19
  import * as ops from "./ops.mjs";
20
+ import { MAX_TAGS, normalizeTags } from "./tags.mjs";
20
21
  import { exportVideo } from "./export-video.mjs";
21
22
  import { presenterLine } from "./presenter.mjs";
22
23
 
@@ -62,14 +63,44 @@ async function whoamiCmd(opts) {
62
63
  console.log(cliLine);
63
64
  }
64
65
 
66
+ // A flag that takes a value but was given none (`--tag` last, or followed by
67
+ // another flag) parses as undefined or as the next flag: refuse it, never
68
+ // read it as "no filter".
69
+ function tagFlag(opts, usage) {
70
+ if (!("tag" in opts)) return undefined;
71
+ const v = opts.tag;
72
+ // Repeated --tag values arrive comma-joined (runtime parse): check each one.
73
+ const parts = typeof v === "string" ? v.split(",") : [];
74
+ if (!parts.length || parts.some((p) => !p.trim() || p === "undefined" || p.startsWith("--"))) throw new Error(`--tag needs a tag name: ${usage}`);
75
+ return v;
76
+ }
77
+
65
78
  async function deckList(opts) {
66
- const rows = await ops.listDecks(opts);
79
+ const tag = tagFlag(opts, "deck list --tag <tag>");
80
+ const rows = await ops.listDecks(opts, { tag });
67
81
  if (opts.json) {
68
82
  console.log(JSON.stringify(rows, null, 2));
69
83
  return;
70
84
  }
71
- for (const d of rows) console.log(`${d.slug}\t${d.status}\t${d.title}`);
72
- if (!rows.length) console.log("(no decks)");
85
+ for (const d of rows) console.log(`${d.slug}\t${d.status}\t${d.title}${d.tags.length ? `\t#${d.tags.join(" #")}` : ""}`);
86
+ if (!rows.length) console.log(tag ? `(no decks tagged ${tag})` : "(no decks)");
87
+ }
88
+
89
+ const TAG_USAGE = "usage: deck tag <slug> add|remove <tag...> [--json]";
90
+
91
+ // Add or remove the deck's tags; with neither, print them.
92
+ async function deckTag(pos, opts) {
93
+ const [slug, action, ...names] = pos;
94
+ if (!slug) throw new Error(TAG_USAGE);
95
+ if (action === undefined) {
96
+ const { tags } = await ops.deckTags(opts, slug);
97
+ if (opts.json) return void console.log(JSON.stringify({ slug, tags }, null, 2));
98
+ return void console.log(tags.length ? `${slug}: ${tags.join(", ")}` : `${slug} has no tags`);
99
+ }
100
+ if ((action !== "add" && action !== "remove") || !names.length) throw new Error(TAG_USAGE);
101
+ const out = await ops.tagDeck(opts, slug, action === "add" ? { add: names } : { remove: names });
102
+ if (opts.json) return void console.log(JSON.stringify(out, null, 2));
103
+ console.log(out.tags.length ? `OK tagged ${out.slug}: ${out.tags.join(", ")}` : `OK ${out.slug} has no tags now`);
73
104
  }
74
105
 
75
106
  async function deckStats(pos, opts) {
@@ -490,7 +521,12 @@ commands:
490
521
  login [--token <pat>] [--broker <url>] [--dev]
491
522
  logout [--dev]
492
523
  whoami [--json] [--dev]
493
- deck list|stats|open|link|archive|unarchive|rm|forward|view|transfer|transfers
524
+ deck list|tag|stats|open|link|archive|unarchive|rm|forward|view|transfer|transfers
525
+ deck list [--tag <tag>] [--json]
526
+ your decks; --tag shows only the ones carrying that tag.
527
+ deck tag <slug> [add|remove <tag...>] [--json]
528
+ label a deck for yourself (investors, fizz-fm…): lowercase a-z 0-9 -, 1–32 characters,
529
+ spaces become -, at most 10 a deck. Only you see them; never recipients. No action: print them.
494
530
  deck archive <slug> | deck unarchive <slug> [--json]
495
531
  set a deck aside, reversibly; nothing is deleted. While archived its share and preview links show
496
532
  "no longer active" and exports are refused. unarchive puts back the status it had (live stays
@@ -515,7 +551,7 @@ commands:
515
551
  how the deck opens in the player (default: as its HTML says, data-view or slides) and
516
552
  whether viewers get the slides/scroll toggle (on by default). Every link, next load; no re-release.
517
553
  --ai-readable: whether each link + /md serves the deck as markdown for AI assistants (on by default).
518
- deck new <slug> "<title>" --narrated [--layouts hero,product,number,closer] [--presenter-style stage|bubble|glass|corner] [--no-brand] [--dir <path>]
554
+ deck new <slug> "<title>" --narrated [--layouts hero,product,number,closer] [--presenter-style stage|bubble|glass|corner] [--no-brand] [--dir <path>] [--tag <tag,...>]
519
555
  scaffold decks/<slug>/: index.html (8 slides, or one per layout, player/v1), script.md, evidence.md,
520
556
  in your saved brand's colours, fonts and logo (--no-brand: the template's look)
521
557
  layouts: hero, cover-frame, cover-split, cover-band, cover-poster, cover-type, number, product, phones, quote,
@@ -968,15 +1004,40 @@ function commandTable(pos, rest, opts) {
968
1004
  if (opts.json) console.log(JSON.stringify(out, null, 2));
969
1005
  },
970
1006
  "deck new": async () => {
1007
+ // --tag: checked before anything is made, applied once the deck is registered.
1008
+ const tagsWanted = "tag" in opts ? normalizeTags(tagFlag(opts, "deck new <slug> \"<title>\" --tag <tag>")) : [];
1009
+ if (tagsWanted.length > MAX_TAGS) throw new Error(`a deck holds at most ${MAX_TAGS} tags`);
1010
+ // A failed tag must not hide the deck that was made: report it beside the
1011
+ // result (tagError) and say how to retry, never as a failed deck new.
1012
+ const tagNew = async (slug) => {
1013
+ if (!tagsWanted.length) return {};
1014
+ try {
1015
+ return { tags: (await ops.tagDeck(opts, slug, { add: tagsWanted })).tags };
1016
+ } catch (e) {
1017
+ const tagError = ops.errorText(e);
1018
+ console.error(`⚠ created ${slug} but tagging failed (${tagError}); run: hyperdecks deck tag ${slug} add ${tagsWanted.join(" ")}`);
1019
+ return { tagError };
1020
+ }
1021
+ };
1022
+ // After the result is printed: exit non-zero without printing the error twice.
1023
+ const tagFailed = (tagged) => {
1024
+ if (tagged.tagError) throw Object.assign(new Error(tagged.tagError), { reported: true });
1025
+ };
971
1026
  if (opts.hosted) {
972
1027
  const { hostedNewDeck } = await import("./source.mjs");
973
1028
  if (!opts.narrated) throw new Error("the published CLI scaffolds narrated decks only: add --narrated");
974
- const out = await hostedNewDeck(opts, { slug: rest[0], title: rest[1], layouts: opts.layouts, presenterStyle: opts["presenter-style"], brand: !opts["no-brand"] });
975
- return void console.log(opts.json ? JSON.stringify(out, null, 2) : `✓ created hosted deck "${out.slug}" (rev ${out.rev})\n preview: ${out.previewUrl}\n edit locally: hyperdecks source pull ${out.slug}`);
1029
+ const created = await hostedNewDeck(opts, { slug: rest[0], title: rest[1], layouts: opts.layouts, presenterStyle: opts["presenter-style"], brand: !opts["no-brand"] });
1030
+ const tagged = await tagNew(created.slug);
1031
+ const out = { ...created, ...tagged };
1032
+ console.log(opts.json ? JSON.stringify(out, null, 2) : `✓ created hosted deck "${out.slug}" (rev ${out.rev})${tagged.tags ? `, tagged ${tagged.tags.join(", ")}` : ""}\n preview: ${out.previewUrl}\n edit locally: hyperdecks source pull ${out.slug}`);
1033
+ return tagFailed(tagged);
976
1034
  }
977
1035
  const { deckNew } = await import("./scaffold.mjs");
978
- const out = await deckNew(rest, opts, opts.json ? { log: (line) => console.error(line) } : {});
979
- if (opts.json) console.log(JSON.stringify(out, null, 2));
1036
+ const created = await deckNew(rest, opts, opts.json ? { log: (line) => console.error(line) } : {});
1037
+ const tagged = await tagNew(created.slug);
1038
+ if (tagged.tags && !opts.json) console.log(`✓ tagged ${created.slug}: ${tagged.tags.join(", ")}`);
1039
+ if (opts.json) console.log(JSON.stringify({ ...created, ...tagged }, null, 2));
1040
+ tagFailed(tagged);
980
1041
  },
981
1042
  check: async () => {
982
1043
  const { check } = await import("./check.mjs");
@@ -1171,6 +1232,7 @@ function commandTable(pos, rest, opts) {
1171
1232
  logout: () => logout(opts),
1172
1233
  whoami: () => whoamiCmd(opts),
1173
1234
  "deck list": () => deckList(opts),
1235
+ "deck tag": () => deckTag(rest, opts),
1174
1236
  "deck stats": () => deckStats(rest, opts),
1175
1237
  "deck open": () => deckOpen(rest, opts),
1176
1238
  "deck link": () => deckLink(rest, opts),
package/src/ops.mjs CHANGED
@@ -4,6 +4,7 @@ import { SPECIES } from "./species.mjs";
4
4
  import { COLOR_KEYS, FONT_PAIRINGS, FONT_ROLES, findPairing, googleFontsUrl } from "./brand.mjs";
5
5
  import { MAX_IMPORT_FILE_BYTES, draftArgs, extractFile } from "./brandImport.mjs";
6
6
  import { api, backupLinkUrl, client, linkBase, target, uploadBytes as runtimeUploadBytes } from "./runtime.mjs";
7
+ import { normalizeTags, TAG_RULE } from "./tags.mjs";
7
8
  import {
8
9
  bytesFromText,
9
10
  isTextAsset,
@@ -32,12 +33,19 @@ export function ownerLink(opts, slug) {
32
33
  return { slug, ownerUrl: url, backupUrl: backupLinkUrl(url) };
33
34
  }
34
35
 
35
- export async function listDecks(opts = {}, { all = false } = {}) {
36
+ // `tag`: only the decks carrying it (normalized the way tags are stored).
37
+ /** @param {any} [opts] @param {{ all?: boolean, tag?: string }} [filter] */
38
+ export async function listDecks(opts = {}, { all = false, tag } = {}) {
39
+ const wanted = tag == null ? [] : normalizeTags(tag);
40
+ if (tag != null && wanted.length !== 1) throw new Error(wanted.length ? "filter by one tag at a time" : `name a tag to filter by: ${TAG_RULE}`);
41
+ const want = wanted[0] ?? null;
36
42
  const rows = await (await client(opts)).query(all ? api.decks.listAll : api.decks.listForViewer, {});
37
- return rows.map((d) => ({
43
+ return rows.filter((d) => !want || (d.tags ?? []).includes(want)).map((d) => ({
38
44
  slug: d.slug,
39
45
  title: d.title,
40
46
  status: d.status,
47
+ // The owner's own labels (deck tag / tag_deck), sorted.
48
+ tags: d.tags ?? [],
41
49
  ownerEmail: d.ownerEmail ?? null,
42
50
  hasHtml: !!(d.html || d.htmlStorageId || d.hasHtml),
43
51
  // How it opens (null: as its HTML says) and whether viewers may switch.
@@ -712,6 +720,26 @@ export async function archiveDeck(opts, slug) {
712
720
  return { slug, status: "archived" };
713
721
  }
714
722
 
723
+ // Tag a deck you own: add and/or remove tags (normalized: lowercase a-z 0-9 -,
724
+ // 1–32 chars, spaces become -; at most 10 a deck). Returns its tags after.
725
+ // A deck's tags, for its owner (or an admin): decks.get answers no one else.
726
+ /** @param {any} opts @param {string} slug */
727
+ export async function deckTags(opts, slug) {
728
+ if (!slug) throw new Error("slug is required");
729
+ const deck = await (await client(opts)).query(api.decks.get, { slug });
730
+ if (!deck) throw new Error(`deck not found: ${slug} (deck list shows your decks)`);
731
+ return { slug, tags: deck.tags ?? [] };
732
+ }
733
+
734
+ /** @param {any} opts @param {string} slug @param {{ add?: string[], remove?: string[] }} [change] */
735
+ export async function tagDeck(opts, slug, { add = [], remove = [] } = {}) {
736
+ if (!slug) throw new Error("slug is required");
737
+ const plus = normalizeTags(add);
738
+ const minus = normalizeTags(remove);
739
+ if (!plus.length && !minus.length) throw new Error("name at least one tag to add or remove");
740
+ return (await client(opts)).mutation(api.decks.setTags, { slug, add: plus, remove: minus });
741
+ }
742
+
715
743
  // Unarchive: back to the status it had before archiving (draft if unknown).
716
744
  export async function unarchiveDeck(opts, slug) {
717
745
  if (!slug) throw new Error("slug is required");
package/src/runtime.mjs CHANGED
@@ -9,7 +9,7 @@ import { ConvexHttpClient } from "convex/browser";
9
9
  import { makeFunctionReference } from "convex/server";
10
10
  import { recordSkillInstall } from "./skillFreshness.mjs";
11
11
 
12
- export const VERSION = "0.9.19";
12
+ export const VERSION = "0.9.20";
13
13
 
14
14
  // Sent on the CLI's calls to our routes and to Convex, so the server can see
15
15
  // which CLI versions are still out there (not used to refuse anything).
@@ -128,6 +128,7 @@ export const api = {
128
128
  remove: makeFunctionReference("decks:remove"),
129
129
  removalPreview: makeFunctionReference("decks:removalPreview"),
130
130
  setStatus: makeFunctionReference("decks:setStatus"),
131
+ setTags: makeFunctionReference("decks:setTags"),
131
132
  unarchive: makeFunctionReference("decks:unarchive"),
132
133
  setAllowForward: makeFunctionReference("decks:setAllowForward"),
133
134
  setView: makeFunctionReference("decks:setView"),
@@ -238,7 +239,7 @@ export function parse(args) {
238
239
  else {
239
240
  const v = args[++i];
240
241
  if (k === "to" || (k === "email" && opts.recipients)) addRecipient(opts, k, v);
241
- if ((k === "agent" || k === "guest") && opts[k]) opts[k] = `${opts[k]},${v}`;
242
+ if ((k === "agent" || k === "guest" || k === "tag") && opts[k]) opts[k] = `${opts[k]},${v}`;
242
243
  else opts[k] = v;
243
244
  }
244
245
  } else {
package/src/tags.mjs ADDED
@@ -0,0 +1,57 @@
1
+ // Deck tags: the owner's own labels for grouping decks (investors, fizz-fm…).
2
+ // One rule, shared by Convex (decks.setTags), the CLI, both MCP servers and the
3
+ // dashboard, so a tag typed anywhere comes out the same: lowercase a-z, 0-9 and
4
+ // "-", 1–32 characters, spaces (and underscores) become "-". A deck holds at
5
+ // most MAX_TAGS, stored deduped and sorted. Owner-only: tags never reach a
6
+ // viewer, a share page, /md or an export.
7
+
8
+ export const MAX_TAGS = 10;
9
+ export const MAX_TAG_LENGTH = 32;
10
+ export const TAG_RULE = `a tag is 1–${MAX_TAG_LENGTH} characters of a-z, 0-9 and "-"`;
11
+
12
+ // One tag in its stored form, or null when nothing usable is left
13
+ // (" Fizz FM " → "fizz-fm"; "!!!" → null). Too long is an error, not a cut:
14
+ // a silently shortened tag would not match what the caller typed.
15
+ /** @param {unknown} raw @returns {string | null} */
16
+ export function normalizeTag(raw) {
17
+ const tag = String(raw ?? "")
18
+ .trim()
19
+ .toLowerCase()
20
+ .replace(/[\s_]+/g, "-")
21
+ .replace(/[^a-z0-9-]/g, "")
22
+ .replace(/-+/g, "-")
23
+ .replace(/^-|-$/g, "");
24
+ if (!tag) return null;
25
+ if (tag.length > MAX_TAG_LENGTH) throw new Error(`tag "${tag.slice(0, 40)}…" is too long: ${TAG_RULE}`);
26
+ return tag;
27
+ }
28
+
29
+ // Several tags (an array, or one comma-separated string) in stored form,
30
+ // deduped, in the order given. An entry with nothing usable is an error.
31
+ /** @param {unknown} list @returns {string[]} */
32
+ export function normalizeTags(list) {
33
+ const items = Array.isArray(list) ? list : String(list ?? "").split(",");
34
+ /** @type {Set<string>} */
35
+ const out = new Set();
36
+ for (const raw of items) {
37
+ for (const part of String(raw ?? "").split(",")) {
38
+ if (!part.trim()) continue;
39
+ const tag = normalizeTag(part);
40
+ if (!tag) throw new Error(`"${part.trim().slice(0, 40)}" is not a tag: ${TAG_RULE}`);
41
+ out.add(tag);
42
+ }
43
+ }
44
+ return [...out];
45
+ }
46
+
47
+ // A deck's tags after adding and removing (remove wins over add for the same
48
+ // tag), deduped and sorted. Throws past MAX_TAGS, naming what is there.
49
+ /** @param {readonly string[] | undefined} current @param {{ add?: readonly string[], remove?: readonly string[] }} [change] @returns {string[]} */
50
+ export function applyTags(current, { add = [], remove = [] } = {}) {
51
+ const drop = new Set(normalizeTags(remove));
52
+ const next = [...new Set([...(current ?? []), ...normalizeTags(add)])].filter((t) => !drop.has(t)).sort();
53
+ if (next.length > MAX_TAGS) {
54
+ throw new Error(`a deck holds at most ${MAX_TAGS} tags (this would make ${next.length}: ${next.join(", ")}); remove some first`);
55
+ }
56
+ return next;
57
+ }