@hypersocial/decks-cli 0.9.19 → 0.9.21
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 +1 -1
- package/skills/hyperdecks/SKILL.md +11 -1
- package/skills/hyperdecks/chat.md +3 -1
- package/src/commands.mjs +90 -9
- package/src/deckSearch.mjs +53 -0
- package/src/ops.mjs +37 -2
- package/src/runtime.mjs +3 -2
- package/src/tags.mjs +57 -0
package/package.json
CHANGED
|
@@ -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.
|
|
5
|
+
version: "0.9.21"
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Hyperdecks
|
|
@@ -1005,6 +1005,16 @@ 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.
|
|
1014
|
+
- To find a deck by who it went to ("the one I sent a16z"): `hyperdecks deck list
|
|
1015
|
+
--search a16z` / `list_decks { search: "a16z" }`. Search matches the title,
|
|
1016
|
+
slug, tags and `sentTo` (each share link's recipient name, email and note; QA
|
|
1017
|
+
links never), the same as the dashboard search; it combines with `tag`.
|
|
1008
1018
|
- To retire a deck ("archive it", "put it away", a superseded draft), archive it:
|
|
1009
1019
|
`hyperdecks deck archive <slug>` / `archive_deck`. It is reversible
|
|
1010
1020
|
(`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. `
|
|
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,8 @@ 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";
|
|
21
|
+
import { sentToLabel, sentToMatch } from "./deckSearch.mjs";
|
|
20
22
|
import { exportVideo } from "./export-video.mjs";
|
|
21
23
|
import { presenterLine } from "./presenter.mjs";
|
|
22
24
|
|
|
@@ -62,14 +64,60 @@ async function whoamiCmd(opts) {
|
|
|
62
64
|
console.log(cliLine);
|
|
63
65
|
}
|
|
64
66
|
|
|
67
|
+
// A flag that takes a value but was given none (`--tag` last, or followed by
|
|
68
|
+
// another flag) parses as undefined or as the next flag: refuse it, never
|
|
69
|
+
// read it as "no filter".
|
|
70
|
+
function tagFlag(opts, usage) {
|
|
71
|
+
if (!("tag" in opts)) return undefined;
|
|
72
|
+
const v = opts.tag;
|
|
73
|
+
// Repeated --tag values arrive comma-joined (runtime parse): check each one.
|
|
74
|
+
const parts = typeof v === "string" ? v.split(",") : [];
|
|
75
|
+
if (!parts.length || parts.some((p) => !p.trim() || p === "undefined" || p.startsWith("--"))) throw new Error(`--tag needs a tag name: ${usage}`);
|
|
76
|
+
return v;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// --search: same refusal as tagFlag for a missing value; the text is free.
|
|
80
|
+
function searchFlag(opts) {
|
|
81
|
+
if (!("search" in opts)) return undefined;
|
|
82
|
+
const v = opts.search;
|
|
83
|
+
if (typeof v !== "string" || !v.trim() || v === "undefined" || v.startsWith("--")) throw new Error("--search needs some text: deck list --search <text>");
|
|
84
|
+
return v;
|
|
85
|
+
}
|
|
86
|
+
|
|
65
87
|
async function deckList(opts) {
|
|
66
|
-
const
|
|
88
|
+
const tag = tagFlag(opts, "deck list --tag <tag>");
|
|
89
|
+
const search = searchFlag(opts);
|
|
90
|
+
const rows = await ops.listDecks(opts, { tag, search });
|
|
67
91
|
if (opts.json) {
|
|
68
92
|
console.log(JSON.stringify(rows, null, 2));
|
|
69
93
|
return;
|
|
70
94
|
}
|
|
71
|
-
for (const d of rows)
|
|
72
|
-
|
|
95
|
+
for (const d of rows) {
|
|
96
|
+
// Found only through who it was sent to: say who, as the dashboard does.
|
|
97
|
+
const sentTo = search ? sentToMatch(d, search) : null;
|
|
98
|
+
console.log(`${d.slug}\t${d.status}\t${d.title}${d.tags.length ? `\t#${d.tags.join(" #")}` : ""}${sentTo ? `\t→ ${sentToLabel(sentTo)}` : ""}`);
|
|
99
|
+
}
|
|
100
|
+
if (!rows.length) {
|
|
101
|
+
if (search) console.log(`(no decks${tag ? ` tagged ${tag}` : ""} match "${search.trim()}")`);
|
|
102
|
+
else console.log(tag ? `(no decks tagged ${tag})` : "(no decks)");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const TAG_USAGE = "usage: deck tag <slug> add|remove <tag...> [--json]";
|
|
107
|
+
|
|
108
|
+
// Add or remove the deck's tags; with neither, print them.
|
|
109
|
+
async function deckTag(pos, opts) {
|
|
110
|
+
const [slug, action, ...names] = pos;
|
|
111
|
+
if (!slug) throw new Error(TAG_USAGE);
|
|
112
|
+
if (action === undefined) {
|
|
113
|
+
const { tags } = await ops.deckTags(opts, slug);
|
|
114
|
+
if (opts.json) return void console.log(JSON.stringify({ slug, tags }, null, 2));
|
|
115
|
+
return void console.log(tags.length ? `${slug}: ${tags.join(", ")}` : `${slug} has no tags`);
|
|
116
|
+
}
|
|
117
|
+
if ((action !== "add" && action !== "remove") || !names.length) throw new Error(TAG_USAGE);
|
|
118
|
+
const out = await ops.tagDeck(opts, slug, action === "add" ? { add: names } : { remove: names });
|
|
119
|
+
if (opts.json) return void console.log(JSON.stringify(out, null, 2));
|
|
120
|
+
console.log(out.tags.length ? `OK tagged ${out.slug}: ${out.tags.join(", ")}` : `OK ${out.slug} has no tags now`);
|
|
73
121
|
}
|
|
74
122
|
|
|
75
123
|
async function deckStats(pos, opts) {
|
|
@@ -490,7 +538,14 @@ commands:
|
|
|
490
538
|
login [--token <pat>] [--broker <url>] [--dev]
|
|
491
539
|
logout [--dev]
|
|
492
540
|
whoami [--json] [--dev]
|
|
493
|
-
deck list|stats|open|link|archive|unarchive|rm|forward|view|transfer|transfers
|
|
541
|
+
deck list|tag|stats|open|link|archive|unarchive|rm|forward|view|transfer|transfers
|
|
542
|
+
deck list [--tag <tag>] [--search <text>] [--json]
|
|
543
|
+
your decks; --tag shows only the ones carrying that tag; --search only those whose
|
|
544
|
+
title, slug, tags or recipients (share link name, email, note) contain the text,
|
|
545
|
+
like the dashboard search (→ shows who it was sent to when only a recipient matched).
|
|
546
|
+
deck tag <slug> [add|remove <tag...>] [--json]
|
|
547
|
+
label a deck for yourself (investors, fizz-fm…): lowercase a-z 0-9 -, 1–32 characters,
|
|
548
|
+
spaces become -, at most 10 a deck. Only you see them; never recipients. No action: print them.
|
|
494
549
|
deck archive <slug> | deck unarchive <slug> [--json]
|
|
495
550
|
set a deck aside, reversibly; nothing is deleted. While archived its share and preview links show
|
|
496
551
|
"no longer active" and exports are refused. unarchive puts back the status it had (live stays
|
|
@@ -515,7 +570,7 @@ commands:
|
|
|
515
570
|
how the deck opens in the player (default: as its HTML says, data-view or slides) and
|
|
516
571
|
whether viewers get the slides/scroll toggle (on by default). Every link, next load; no re-release.
|
|
517
572
|
--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>]
|
|
573
|
+
deck new <slug> "<title>" --narrated [--layouts hero,product,number,closer] [--presenter-style stage|bubble|glass|corner] [--no-brand] [--dir <path>] [--tag <tag,...>]
|
|
519
574
|
scaffold decks/<slug>/: index.html (8 slides, or one per layout, player/v1), script.md, evidence.md,
|
|
520
575
|
in your saved brand's colours, fonts and logo (--no-brand: the template's look)
|
|
521
576
|
layouts: hero, cover-frame, cover-split, cover-band, cover-poster, cover-type, number, product, phones, quote,
|
|
@@ -968,15 +1023,40 @@ function commandTable(pos, rest, opts) {
|
|
|
968
1023
|
if (opts.json) console.log(JSON.stringify(out, null, 2));
|
|
969
1024
|
},
|
|
970
1025
|
"deck new": async () => {
|
|
1026
|
+
// --tag: checked before anything is made, applied once the deck is registered.
|
|
1027
|
+
const tagsWanted = "tag" in opts ? normalizeTags(tagFlag(opts, "deck new <slug> \"<title>\" --tag <tag>")) : [];
|
|
1028
|
+
if (tagsWanted.length > MAX_TAGS) throw new Error(`a deck holds at most ${MAX_TAGS} tags`);
|
|
1029
|
+
// A failed tag must not hide the deck that was made: report it beside the
|
|
1030
|
+
// result (tagError) and say how to retry, never as a failed deck new.
|
|
1031
|
+
const tagNew = async (slug) => {
|
|
1032
|
+
if (!tagsWanted.length) return {};
|
|
1033
|
+
try {
|
|
1034
|
+
return { tags: (await ops.tagDeck(opts, slug, { add: tagsWanted })).tags };
|
|
1035
|
+
} catch (e) {
|
|
1036
|
+
const tagError = ops.errorText(e);
|
|
1037
|
+
console.error(`⚠ created ${slug} but tagging failed (${tagError}); run: hyperdecks deck tag ${slug} add ${tagsWanted.join(" ")}`);
|
|
1038
|
+
return { tagError };
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
// After the result is printed: exit non-zero without printing the error twice.
|
|
1042
|
+
const tagFailed = (tagged) => {
|
|
1043
|
+
if (tagged.tagError) throw Object.assign(new Error(tagged.tagError), { reported: true });
|
|
1044
|
+
};
|
|
971
1045
|
if (opts.hosted) {
|
|
972
1046
|
const { hostedNewDeck } = await import("./source.mjs");
|
|
973
1047
|
if (!opts.narrated) throw new Error("the published CLI scaffolds narrated decks only: add --narrated");
|
|
974
|
-
const
|
|
975
|
-
|
|
1048
|
+
const created = await hostedNewDeck(opts, { slug: rest[0], title: rest[1], layouts: opts.layouts, presenterStyle: opts["presenter-style"], brand: !opts["no-brand"] });
|
|
1049
|
+
const tagged = await tagNew(created.slug);
|
|
1050
|
+
const out = { ...created, ...tagged };
|
|
1051
|
+
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}`);
|
|
1052
|
+
return tagFailed(tagged);
|
|
976
1053
|
}
|
|
977
1054
|
const { deckNew } = await import("./scaffold.mjs");
|
|
978
|
-
const
|
|
979
|
-
|
|
1055
|
+
const created = await deckNew(rest, opts, opts.json ? { log: (line) => console.error(line) } : {});
|
|
1056
|
+
const tagged = await tagNew(created.slug);
|
|
1057
|
+
if (tagged.tags && !opts.json) console.log(`✓ tagged ${created.slug}: ${tagged.tags.join(", ")}`);
|
|
1058
|
+
if (opts.json) console.log(JSON.stringify({ ...created, ...tagged }, null, 2));
|
|
1059
|
+
tagFailed(tagged);
|
|
980
1060
|
},
|
|
981
1061
|
check: async () => {
|
|
982
1062
|
const { check } = await import("./check.mjs");
|
|
@@ -1171,6 +1251,7 @@ function commandTable(pos, rest, opts) {
|
|
|
1171
1251
|
logout: () => logout(opts),
|
|
1172
1252
|
whoami: () => whoamiCmd(opts),
|
|
1173
1253
|
"deck list": () => deckList(opts),
|
|
1254
|
+
"deck tag": () => deckTag(rest, opts),
|
|
1174
1255
|
"deck stats": () => deckStats(rest, opts),
|
|
1175
1256
|
"deck open": () => deckOpen(rest, opts),
|
|
1176
1257
|
"deck link": () => deckLink(rest, opts),
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Deck text search, shared by the dashboard (lib/deckSort.ts filterDecks), the
|
|
2
|
+
// CLI (`deck list --search`) and both MCPs (list_decks search), so one search
|
|
3
|
+
// finds the same decks everywhere. Pure: no Convex, no React.
|
|
4
|
+
//
|
|
5
|
+
// One case-insensitive substring test over the deck's title, slug and tags,
|
|
6
|
+
// and over each person it was sent to (decks.listForViewer sentTo: the link's
|
|
7
|
+
// recipient name, email and note; QA links never appear there).
|
|
8
|
+
|
|
9
|
+
/** @typedef {{ name: string, email?: string, note?: string }} SentTo */
|
|
10
|
+
/** @typedef {{ title: string, slug: string, tags?: string[], sentTo?: SentTo[] }} SearchableDeck */
|
|
11
|
+
|
|
12
|
+
/** @param {string | null | undefined} q */
|
|
13
|
+
export const searchNeedle = (q) => (q ?? "").trim().toLowerCase();
|
|
14
|
+
|
|
15
|
+
/** @param {string | null | undefined} s @param {string} needle */
|
|
16
|
+
const has = (s, needle) => !!s && s.toLowerCase().includes(needle);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Whether the deck matches the search, and how. null: no match (or an empty
|
|
20
|
+
* search, which every deck passes: callers skip searching then). `sentTo`
|
|
21
|
+
* lists the recipients that matched, and is empty when the deck's own title,
|
|
22
|
+
* slug or a tag matched: only a recipient-only match needs explaining.
|
|
23
|
+
* @param {SearchableDeck} deck
|
|
24
|
+
* @param {string | null | undefined} q
|
|
25
|
+
* @returns {{ sentTo: SentTo[] } | null}
|
|
26
|
+
*/
|
|
27
|
+
export function deckSearchMatch(deck, q) {
|
|
28
|
+
const needle = searchNeedle(q);
|
|
29
|
+
if (!needle) return null;
|
|
30
|
+
if (has(deck.title, needle) || has(deck.slug, needle) || (deck.tags ?? []).some((t) => has(t, needle))) return { sentTo: [] };
|
|
31
|
+
const sentTo = (deck.sentTo ?? []).filter((r) => has(r.name, needle) || has(r.email, needle) || has(r.note, needle));
|
|
32
|
+
return sentTo.length ? { sentTo } : null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** @param {SearchableDeck} deck @param {string | null | undefined} q */
|
|
36
|
+
export const deckMatchesSearch = (deck, q) => !searchNeedle(q) || deckSearchMatch(deck, q) !== null;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Who a recipient-only match was sent to, for the "Sent to …" line: the first
|
|
40
|
+
* matching name and how many more ("a16z +2"). null when the deck matched on
|
|
41
|
+
* its own title, slug or tags, or not at all.
|
|
42
|
+
* @param {SearchableDeck} deck
|
|
43
|
+
* @param {string | null | undefined} q
|
|
44
|
+
* @returns {{ name: string, more: number } | null}
|
|
45
|
+
*/
|
|
46
|
+
export function sentToMatch(deck, q) {
|
|
47
|
+
const hit = deckSearchMatch(deck, q);
|
|
48
|
+
if (!hit?.sentTo.length) return null;
|
|
49
|
+
return { name: hit.sentTo[0].name, more: hit.sentTo.length - 1 };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** @param {{ name: string, more: number }} m */
|
|
53
|
+
export const sentToLabel = (m) => (m.more ? `${m.name} +${m.more}` : m.name);
|
package/src/ops.mjs
CHANGED
|
@@ -4,6 +4,8 @@ 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";
|
|
8
|
+
import { deckMatchesSearch } from "./deckSearch.mjs";
|
|
7
9
|
import {
|
|
8
10
|
bytesFromText,
|
|
9
11
|
isTextAsset,
|
|
@@ -32,12 +34,25 @@ export function ownerLink(opts, slug) {
|
|
|
32
34
|
return { slug, ownerUrl: url, backupUrl: backupLinkUrl(url) };
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
// `tag`: only the decks carrying it (normalized the way tags are stored).
|
|
38
|
+
// `search`: only the decks whose title, slug, tags or recipients (sentTo: the
|
|
39
|
+
// share links' names, emails and notes, never QA links) contain the text, the
|
|
40
|
+
// dashboard's search (deckSearch.mjs). An admin's `all` carries no recipients.
|
|
41
|
+
/** @param {any} [opts] @param {{ all?: boolean, tag?: string, search?: string }} [filter] */
|
|
42
|
+
export async function listDecks(opts = {}, { all = false, tag, search } = {}) {
|
|
43
|
+
const wanted = tag == null ? [] : normalizeTags(tag);
|
|
44
|
+
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}`);
|
|
45
|
+
const want = wanted[0] ?? null;
|
|
36
46
|
const rows = await (await client(opts)).query(all ? api.decks.listAll : api.decks.listForViewer, {});
|
|
37
|
-
return rows.map((d) => ({
|
|
47
|
+
return rows.filter((d) => (!want || (d.tags ?? []).includes(want)) && deckMatchesSearch({ ...d, sentTo: all ? [] : d.sentTo }, search)).map((d) => ({
|
|
38
48
|
slug: d.slug,
|
|
39
49
|
title: d.title,
|
|
40
50
|
status: d.status,
|
|
51
|
+
// The owner's own labels (deck tag / tag_deck), sorted.
|
|
52
|
+
tags: d.tags ?? [],
|
|
53
|
+
// Who it was sent to ({ name, email?, note? } per non-QA link, newest
|
|
54
|
+
// first); empty for an admin's all.
|
|
55
|
+
sentTo: all ? [] : d.sentTo ?? [],
|
|
41
56
|
ownerEmail: d.ownerEmail ?? null,
|
|
42
57
|
hasHtml: !!(d.html || d.htmlStorageId || d.hasHtml),
|
|
43
58
|
// How it opens (null: as its HTML says) and whether viewers may switch.
|
|
@@ -712,6 +727,26 @@ export async function archiveDeck(opts, slug) {
|
|
|
712
727
|
return { slug, status: "archived" };
|
|
713
728
|
}
|
|
714
729
|
|
|
730
|
+
// Tag a deck you own: add and/or remove tags (normalized: lowercase a-z 0-9 -,
|
|
731
|
+
// 1–32 chars, spaces become -; at most 10 a deck). Returns its tags after.
|
|
732
|
+
// A deck's tags, for its owner (or an admin): decks.get answers no one else.
|
|
733
|
+
/** @param {any} opts @param {string} slug */
|
|
734
|
+
export async function deckTags(opts, slug) {
|
|
735
|
+
if (!slug) throw new Error("slug is required");
|
|
736
|
+
const deck = await (await client(opts)).query(api.decks.get, { slug });
|
|
737
|
+
if (!deck) throw new Error(`deck not found: ${slug} (deck list shows your decks)`);
|
|
738
|
+
return { slug, tags: deck.tags ?? [] };
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/** @param {any} opts @param {string} slug @param {{ add?: string[], remove?: string[] }} [change] */
|
|
742
|
+
export async function tagDeck(opts, slug, { add = [], remove = [] } = {}) {
|
|
743
|
+
if (!slug) throw new Error("slug is required");
|
|
744
|
+
const plus = normalizeTags(add);
|
|
745
|
+
const minus = normalizeTags(remove);
|
|
746
|
+
if (!plus.length && !minus.length) throw new Error("name at least one tag to add or remove");
|
|
747
|
+
return (await client(opts)).mutation(api.decks.setTags, { slug, add: plus, remove: minus });
|
|
748
|
+
}
|
|
749
|
+
|
|
715
750
|
// Unarchive: back to the status it had before archiving (draft if unknown).
|
|
716
751
|
export async function unarchiveDeck(opts, slug) {
|
|
717
752
|
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.
|
|
12
|
+
export const VERSION = "0.9.21";
|
|
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
|
+
}
|