@appeeky/open-slideshow 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +297 -2
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +9 -0
- package/dist/brand.d.ts +57 -0
- package/dist/brand.js +263 -0
- package/dist/brandkit.d.ts +50 -0
- package/dist/brandkit.js +212 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +355 -0
- package/dist/decks.d.ts +44 -0
- package/dist/decks.js +100 -0
- package/dist/fonts.d.ts +45 -0
- package/dist/fonts.js +243 -0
- package/dist/gallery.d.ts +35 -0
- package/dist/gallery.js +109 -0
- package/dist/ideas.d.ts +50 -0
- package/dist/ideas.js +146 -0
- package/dist/images.d.ts +62 -0
- package/dist/images.js +241 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +22 -0
- package/dist/lint.d.ts +36 -0
- package/dist/lint.js +197 -0
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.js +303 -0
- package/dist/preview.d.ts +18 -0
- package/dist/preview.js +96 -0
- package/dist/publish.d.ts +105 -0
- package/dist/publish.js +406 -0
- package/dist/readability.d.ts +19 -0
- package/dist/readability.js +42 -0
- package/dist/render.d.ts +92 -0
- package/dist/render.js +647 -0
- package/dist/results.d.ts +89 -0
- package/dist/results.js +252 -0
- package/dist/schedule.d.ts +19 -0
- package/dist/schedule.js +114 -0
- package/dist/schema.d.ts +1159 -0
- package/dist/schema.js +211 -0
- package/dist/screenshots.d.ts +18 -0
- package/dist/screenshots.js +69 -0
- package/dist/shape.d.ts +31 -0
- package/dist/shape.js +169 -0
- package/dist/skill.d.ts +7 -0
- package/dist/skill.js +17 -0
- package/dist/templates.d.ts +47 -0
- package/dist/templates.js +330 -0
- package/dist/text.d.ts +40 -0
- package/dist/text.js +231 -0
- package/dist/themes.d.ts +43 -0
- package/dist/themes.js +202 -0
- package/dist/variants.d.ts +48 -0
- package/dist/variants.js +175 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/dist/video.d.ts +22 -0
- package/dist/video.js +59 -0
- package/dist/viral.d.ts +12 -0
- package/dist/viral.js +35 -0
- package/dist/workspace.d.ts +85 -0
- package/dist/workspace.js +322 -0
- package/package.json +65 -4
- package/skills/open-slideshow/SKILL.md +65 -0
- package/skills/open-slideshow/references/brand.md +64 -0
- package/skills/open-slideshow/references/channels.md +63 -0
- package/skills/open-slideshow/references/ideas.md +23 -0
- package/skills/open-slideshow/references/images.md +61 -0
- package/skills/open-slideshow/references/languages.md +51 -0
- package/skills/open-slideshow/references/publishing.md +70 -0
- package/skills/open-slideshow/references/results.md +47 -0
- package/skills/open-slideshow/references/review.md +81 -0
- package/skills/open-slideshow/references/screenshots.md +26 -0
- package/skills/open-slideshow/references/series.md +20 -0
- package/skills/open-slideshow/references/templates.md +96 -0
- package/skills/open-slideshow/references/troubleshooting.md +92 -0
- package/skills/open-slideshow/references/video.md +18 -0
- package/skills/open-slideshow/references/writing.md +76 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Colors } from "./schema.js";
|
|
2
|
+
import { type Workspace } from "./workspace.js";
|
|
3
|
+
/** A web page or stylesheet as text, over https only, never from a private address. */
|
|
4
|
+
export declare function fetchText(raw: string, max?: number): Promise<{
|
|
5
|
+
url: string;
|
|
6
|
+
text: string;
|
|
7
|
+
}>;
|
|
8
|
+
/** Colours in some CSS or HTML, most used first, with the brand's own variables counted extra. */
|
|
9
|
+
export declare function colorsIn(text: string): {
|
|
10
|
+
hex: string;
|
|
11
|
+
count: number;
|
|
12
|
+
}[];
|
|
13
|
+
/** Font families named in the CSS and Google Fonts links. */
|
|
14
|
+
export declare function fontsIn(text: string): string[];
|
|
15
|
+
/** The best logo on the page: an Apple touch icon, then the largest icon. Never the share image: it is a banner, not a logo. */
|
|
16
|
+
export declare function logoIn(html: string, base: string): string | undefined;
|
|
17
|
+
/** Picks a background, text and accent from the brand's colours, keeping text readable. */
|
|
18
|
+
export declare function proposeColors(found: string[], opts?: {
|
|
19
|
+
dark?: boolean;
|
|
20
|
+
}): {
|
|
21
|
+
colors: Colors;
|
|
22
|
+
why: string[];
|
|
23
|
+
};
|
|
24
|
+
/** The theme whose fonts are closest to the brand's. */
|
|
25
|
+
export declare function themeForFonts(fonts: string[]): {
|
|
26
|
+
theme: string;
|
|
27
|
+
why: string;
|
|
28
|
+
} | undefined;
|
|
29
|
+
export interface BrandKit {
|
|
30
|
+
source: string;
|
|
31
|
+
colors_found: string[];
|
|
32
|
+
colors: Colors;
|
|
33
|
+
fonts: string[];
|
|
34
|
+
theme?: {
|
|
35
|
+
theme: string;
|
|
36
|
+
why: string;
|
|
37
|
+
};
|
|
38
|
+
logo?: string;
|
|
39
|
+
notes: string[];
|
|
40
|
+
applied: boolean;
|
|
41
|
+
icon?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Brand colours, fonts and logo from the app's website (or the playbook in a Spec repo). It only
|
|
45
|
+
* proposes; with apply it saves the colours as the brand colours and imports the logo as the icon.
|
|
46
|
+
*/
|
|
47
|
+
export declare function brandKit(ws: Workspace, opts?: {
|
|
48
|
+
url?: string;
|
|
49
|
+
apply?: boolean;
|
|
50
|
+
}): Promise<BrandKit>;
|
package/dist/brandkit.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { fetchAppStore } from "./brand.js";
|
|
3
|
+
import { assertPublicUrl, importImageFromUrl } from "./images.js";
|
|
4
|
+
import { contrast, hexToRgb, luminance, readableOn, rgbToHex, THEMES } from "./themes.js";
|
|
5
|
+
import { saveSettings, UserError } from "./workspace.js";
|
|
6
|
+
const MAX_PAGE = 2 * 1024 * 1024;
|
|
7
|
+
/** A web page or stylesheet as text, over https only, never from a private address. */
|
|
8
|
+
export async function fetchText(raw, max = MAX_PAGE) {
|
|
9
|
+
let current = raw;
|
|
10
|
+
for (let hop = 0; hop < 4; hop++) {
|
|
11
|
+
const url = await assertPublicUrl(current);
|
|
12
|
+
const res = await fetch(url, { redirect: "manual", signal: AbortSignal.timeout(15_000), headers: { "user-agent": "open-slideshow", accept: "text/html,text/css,*/*;q=0.5" } });
|
|
13
|
+
if (res.status >= 300 && res.status < 400) {
|
|
14
|
+
const loc = res.headers.get("location");
|
|
15
|
+
if (!loc)
|
|
16
|
+
throw new UserError("redirect without a location");
|
|
17
|
+
current = new URL(loc, url).toString();
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (res.status === 401 || res.status === 403 || res.status === 429)
|
|
21
|
+
throw new UserError(`${url.hostname} refused to be read (HTTP ${res.status}); try again later, or give the brand colours with brand_set colors`);
|
|
22
|
+
if (!res.ok)
|
|
23
|
+
throw new UserError(`${url.hostname}: HTTP ${res.status}`);
|
|
24
|
+
const chunks = [];
|
|
25
|
+
let total = 0;
|
|
26
|
+
for await (const chunk of res.body) {
|
|
27
|
+
total += chunk.byteLength;
|
|
28
|
+
if (total > max)
|
|
29
|
+
break;
|
|
30
|
+
chunks.push(Buffer.from(chunk));
|
|
31
|
+
}
|
|
32
|
+
return { url: url.toString(), text: Buffer.concat(chunks).toString("utf8") };
|
|
33
|
+
}
|
|
34
|
+
throw new UserError("too many redirects");
|
|
35
|
+
}
|
|
36
|
+
const HEX = /#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b/g;
|
|
37
|
+
const RGB = /rgba?\(\s*(\d{1,3})[\s,]+(\d{1,3})[\s,]+(\d{1,3})/g;
|
|
38
|
+
function normHex(h) {
|
|
39
|
+
const x = h.replace("#", "").toLowerCase();
|
|
40
|
+
return `#${x.length === 3 ? [...x].map((c) => c + c).join("") : x}`;
|
|
41
|
+
}
|
|
42
|
+
const saturation = (hex) => {
|
|
43
|
+
const [r, g, b] = hexToRgb(hex).map((v) => v / 255);
|
|
44
|
+
const max = Math.max(r, g, b);
|
|
45
|
+
const min = Math.min(r, g, b);
|
|
46
|
+
return max === 0 ? 0 : (max - min) / max;
|
|
47
|
+
};
|
|
48
|
+
/** Colours in some CSS or HTML, most used first, with the brand's own variables counted extra. */
|
|
49
|
+
export function colorsIn(text) {
|
|
50
|
+
const counts = new Map();
|
|
51
|
+
const add = (hex, n = 1) => counts.set(hex, (counts.get(hex) ?? 0) + n);
|
|
52
|
+
for (const m of text.matchAll(HEX))
|
|
53
|
+
add(normHex(m[0]));
|
|
54
|
+
for (const m of text.matchAll(RGB))
|
|
55
|
+
add(rgbToHex([Number(m[1]), Number(m[2]), Number(m[3])].map((v) => Math.min(255, v))));
|
|
56
|
+
// --brand, --primary, --accent… and <meta name="theme-color"> say what the brand colour is.
|
|
57
|
+
for (const m of text.matchAll(/--(?:brand|primary|accent|main|theme)[\w-]*\s*:\s*(#[0-9a-fA-F]{3,6})\b/g))
|
|
58
|
+
add(normHex(m[1]), 25);
|
|
59
|
+
for (const m of text.matchAll(/<meta[^>]+name=["']theme-color["'][^>]*content=["'](#[0-9a-fA-F]{3,6})["']/gi))
|
|
60
|
+
add(normHex(m[1]), 40);
|
|
61
|
+
for (const m of text.matchAll(/<meta[^>]+content=["'](#[0-9a-fA-F]{3,6})["'][^>]*name=["']theme-color["']/gi))
|
|
62
|
+
add(normHex(m[1]), 40);
|
|
63
|
+
return [...counts.entries()].map(([hex, count]) => ({ hex, count })).sort((a, b) => b.count - a.count);
|
|
64
|
+
}
|
|
65
|
+
/** Font families named in the CSS and Google Fonts links. */
|
|
66
|
+
export function fontsIn(text) {
|
|
67
|
+
const out = new Map();
|
|
68
|
+
const add = (f) => {
|
|
69
|
+
const name = f.trim().replace(/^["']|["']$/g, "");
|
|
70
|
+
if (!name || /[:;{}()]/.test(name) || name.length > 40 || /^(inherit|initial|sans-serif|serif|monospace|system-ui|-apple-system|blinkmacsystemfont|var\(.*|ui-[\w-]+|arial|helvetica( neue)?|segoe ui|roboto|apple color emoji|segoe ui emoji)$/i.test(name))
|
|
71
|
+
return;
|
|
72
|
+
out.set(name, (out.get(name) ?? 0) + 1);
|
|
73
|
+
};
|
|
74
|
+
for (const m of text.matchAll(/font-family\s*:\s*([^;}"']+(?:["'][^"']+["'][^;}]*)?)/gi))
|
|
75
|
+
add(m[1].split(",")[0]);
|
|
76
|
+
for (const m of text.matchAll(/fonts\.googleapis\.com\/css2?\?family=([^"'&>]+)/gi))
|
|
77
|
+
for (const f of decodeURIComponent(m[1]).split("&family="))
|
|
78
|
+
add(f.split(":")[0].replace(/\+/g, " "));
|
|
79
|
+
return [...out.entries()].sort((a, b) => b[1] - a[1]).map(([f]) => f).slice(0, 5);
|
|
80
|
+
}
|
|
81
|
+
/** The best logo on the page: an Apple touch icon, then the largest icon. Never the share image: it is a banner, not a logo. */
|
|
82
|
+
export function logoIn(html, base) {
|
|
83
|
+
const links = [...html.matchAll(/<link[^>]+>/gi)].map((m) => m[0]);
|
|
84
|
+
const href = (tag) => tag.match(/href=["']([^"']+)["']/i)?.[1];
|
|
85
|
+
const touch = links.find((l) => /rel=["'][^"']*apple-touch-icon/i.test(l));
|
|
86
|
+
const icon = links.filter((l) => /rel=["'][^"']*icon/i.test(l)).sort((a, b) => Number(b.match(/sizes=["'](\d+)/)?.[1] ?? 0) - Number(a.match(/sizes=["'](\d+)/)?.[1] ?? 0))[0];
|
|
87
|
+
for (const c of [touch && href(touch), icon && href(icon)]) {
|
|
88
|
+
if (!c || /\.(svgz?|ico)(\?|$)/i.test(c))
|
|
89
|
+
continue;
|
|
90
|
+
try {
|
|
91
|
+
return new URL(c, base).toString();
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
/* not a URL */
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
/** Picks a background, text and accent from the brand's colours, keeping text readable. */
|
|
100
|
+
export function proposeColors(found, opts = {}) {
|
|
101
|
+
const why = [];
|
|
102
|
+
const neutral = (h) => saturation(h) < 0.12;
|
|
103
|
+
const vivid = found.filter((h) => saturation(h) > 0.35 && luminance(h) > 0.03 && luminance(h) < 0.85);
|
|
104
|
+
const accent = vivid[0] ?? found.find((h) => luminance(h) > 0.03 && luminance(h) < 0.9) ?? "#ff4d6d";
|
|
105
|
+
// Backgrounds and text are the site's near-greys; a pastel is an accent, not a page.
|
|
106
|
+
const darks = found.filter((h) => luminance(h) < 0.03 && neutral(h));
|
|
107
|
+
const lights = found.filter((h) => luminance(h) > 0.85 && neutral(h));
|
|
108
|
+
// A light page unless the site says it is dark (its theme-color) or has no light greys at all.
|
|
109
|
+
const darkSite = !!darks.length && (opts.dark || !lights.length);
|
|
110
|
+
const bg = darkSite ? darks[0] : lights.find((h) => h !== "#ffffff") ?? "#ffffff";
|
|
111
|
+
let fg = darkSite ? lights[0] ?? "#ffffff" : darks[0] ?? "#111111";
|
|
112
|
+
if (contrast(fg, bg) < 4.5) {
|
|
113
|
+
fg = readableOn(bg);
|
|
114
|
+
why.push("text colour changed to stay readable on the background");
|
|
115
|
+
}
|
|
116
|
+
if (contrast(accent, bg) < 3)
|
|
117
|
+
why.push(`the accent ${accent} is faint on ${bg}: use a theme where *words* sit on an accent box (highlight-box), or pick another accent`);
|
|
118
|
+
why.unshift(`accent ${accent} is the brand's most used strong colour`);
|
|
119
|
+
return { colors: { bg, fg, accent }, why };
|
|
120
|
+
}
|
|
121
|
+
/** The theme whose fonts are closest to the brand's. */
|
|
122
|
+
export function themeForFonts(fonts) {
|
|
123
|
+
const f = fonts.join(" ").toLowerCase();
|
|
124
|
+
if (!f)
|
|
125
|
+
return undefined;
|
|
126
|
+
if (/serif|playfair|lora|merriweather|garamond|libre baskerville|dm serif|fraunces|instrument serif|crimson/.test(f) && !/sans/.test(f))
|
|
127
|
+
return { theme: "editorial-ink", why: "the brand uses a serif" };
|
|
128
|
+
if (/anton|bebas|oswald|league gothic|archivo black|condensed|impact/.test(f))
|
|
129
|
+
return { theme: "bold-poster", why: "the brand uses a tall, condensed display font" };
|
|
130
|
+
if (/inter|sf pro|geist|manrope|dm sans|plus jakarta|poppins|nunito|work sans|outfit/.test(f))
|
|
131
|
+
return { theme: "clean-note", why: "the brand uses a clean sans-serif" };
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Brand colours, fonts and logo from the app's website (or the playbook in a Spec repo). It only
|
|
136
|
+
* proposes; with apply it saves the colours as the brand colours and imports the logo as the icon.
|
|
137
|
+
*/
|
|
138
|
+
export async function brandKit(ws, opts = {}) {
|
|
139
|
+
const notes = [];
|
|
140
|
+
let text = "";
|
|
141
|
+
let source = "";
|
|
142
|
+
let logo;
|
|
143
|
+
let url = opts.url;
|
|
144
|
+
if (!url && ws.settings.app.app_store_id) {
|
|
145
|
+
const store = await fetchAppStore(ws, ws.settings.app.app_store_id, ws.settings.app.country);
|
|
146
|
+
if (store?.seller)
|
|
147
|
+
notes.push(`App Store seller: ${store.seller}`);
|
|
148
|
+
const lookup = await fetch(`https://itunes.apple.com/lookup?id=${encodeURIComponent(ws.settings.app.app_store_id)}`, { signal: AbortSignal.timeout(10_000) })
|
|
149
|
+
.then((r) => r.json())
|
|
150
|
+
.catch(() => ({ results: [] }));
|
|
151
|
+
url = lookup.results?.[0]?.sellerUrl;
|
|
152
|
+
}
|
|
153
|
+
if (url) {
|
|
154
|
+
const page = await fetchText(url);
|
|
155
|
+
source = page.url;
|
|
156
|
+
text = page.text;
|
|
157
|
+
logo = logoIn(page.text, page.url);
|
|
158
|
+
// Same-site stylesheets hold most of the colours.
|
|
159
|
+
const sheets = [...page.text.matchAll(/<link[^>]+rel=["']stylesheet["'][^>]*>/gi)].map((m) => m[0].match(/href=["']([^"']+)["']/i)?.[1]).filter((h) => !!h);
|
|
160
|
+
for (const href of sheets.slice(0, 4)) {
|
|
161
|
+
try {
|
|
162
|
+
const u = new URL(href, page.url);
|
|
163
|
+
if (u.hostname !== new URL(page.url).hostname)
|
|
164
|
+
continue;
|
|
165
|
+
text += `\n${(await fetchText(u.toString(), 600_000)).text}`;
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
/* a stylesheet that does not load is fine */
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (ws.spec?.playbook && existsSync(ws.spec.playbook)) {
|
|
173
|
+
const pb = readFileSync(ws.spec.playbook, "utf8");
|
|
174
|
+
if (/#[0-9a-fA-F]{3,6}\b/.test(pb)) {
|
|
175
|
+
text = `${pb.split("\n").filter((l) => /colou?r|brand|#[0-9a-f]{3,6}/i.test(l)).join("\n")}\n${text}`;
|
|
176
|
+
source = source ? `${source} + appeeky/playbook.md` : "appeeky/playbook.md";
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (!text)
|
|
180
|
+
throw new UserError(ws.settings.app.app_store_id ? "the App Store listing names no website for this app; give the website (url)" : "give the app's website (url), or set the App Store id so its seller website can be read");
|
|
181
|
+
const found = colorsIn(text).map((c) => c.hex);
|
|
182
|
+
if (!found.length)
|
|
183
|
+
throw new UserError(`no colours found on ${source}; give the brand colours with brand_set colors`);
|
|
184
|
+
const themeColor = text.match(/<meta[^>]+name=["']theme-color["'][^>]*content=["'](#[0-9a-fA-F]{3,6})["']/i)?.[1];
|
|
185
|
+
const { colors, why } = proposeColors(found, { dark: !!themeColor && luminance(normHex(themeColor)) < 0.03 });
|
|
186
|
+
notes.push(...why);
|
|
187
|
+
const fonts = fontsIn(text);
|
|
188
|
+
const theme = themeForFonts(fonts);
|
|
189
|
+
if (fonts.length && !theme)
|
|
190
|
+
notes.push(`the brand's fonts (${fonts.join(", ")}) are not built in; the themes use TikTok Sans, Inter, Anton and Instrument Serif`);
|
|
191
|
+
let icon;
|
|
192
|
+
if (opts.apply) {
|
|
193
|
+
const s = structuredClone(ws.settings);
|
|
194
|
+
s.brand.colors = colors;
|
|
195
|
+
if (logo && !s.brand.icon) {
|
|
196
|
+
try {
|
|
197
|
+
// Icons are small (a touch icon is 180 px); the app slide draws them small too.
|
|
198
|
+
icon = (await importImageFromUrl(ws, logo, { source: "website", license: "own", note: "brand logo" }, { minSize: 120 })).ref;
|
|
199
|
+
s.brand.icon = icon;
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
notes.push(`the logo could not be imported (${e.message}); import it with image_import`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (!logo && !s.brand.icon)
|
|
206
|
+
notes.push("no logo found on the site (only a favicon); import the app icon with image_import, or set the App Store id");
|
|
207
|
+
if (theme && THEMES.some((t) => t.id === theme.theme))
|
|
208
|
+
notes.push(`try the ${theme.theme} theme (${theme.why})`);
|
|
209
|
+
saveSettings(ws, s);
|
|
210
|
+
}
|
|
211
|
+
return { source, colors_found: found.slice(0, 12), colors, fonts, ...(theme ? { theme } : {}), ...(logo ? { logo } : {}), notes, applied: !!opts.apply, ...(icon ? { icon } : {}) };
|
|
212
|
+
}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function main(argv?: string[]): Promise<number>;
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { existsSync, readFileSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
4
|
+
import YAML from "yaml";
|
|
5
|
+
import { brandContext } from "./brand.js";
|
|
6
|
+
import { newDeck, renderDeckById } from "./decks.js";
|
|
7
|
+
import { templateGallery, themeGallery } from "./gallery.js";
|
|
8
|
+
import { importImageFromFile, importImageFromUrl, searchImages } from "./images.js";
|
|
9
|
+
import { lintDeck } from "./lint.js";
|
|
10
|
+
import { publishDeck } from "./publish.js";
|
|
11
|
+
import { viralLines, viralSearch } from "./viral.js";
|
|
12
|
+
import { dueSlots, planSlots, savePlan } from "./schedule.js";
|
|
13
|
+
import { SKILL, guideText, guideTopics } from "./skill.js";
|
|
14
|
+
import { THEMES } from "./themes.js";
|
|
15
|
+
import { TEMPLATES, shapeText } from "./templates.js";
|
|
16
|
+
import { initWorkspace, listChannels, listDecks, loadDeck, openWorkspace, UserError, writeAtomic } from "./workspace.js";
|
|
17
|
+
import { VERSION } from "./version.js";
|
|
18
|
+
import { insights, recordResult, syncResults } from "./results.js";
|
|
19
|
+
import { collectIdeas, readIdeas } from "./ideas.js";
|
|
20
|
+
import { listSeries } from "./variants.js";
|
|
21
|
+
import { brandKit } from "./brandkit.js";
|
|
22
|
+
import { appScreenshots } from "./screenshots.js";
|
|
23
|
+
import { renderVideo } from "./video.js";
|
|
24
|
+
import { previewDeck } from "./preview.js";
|
|
25
|
+
import { setImageLicense } from "./images.js";
|
|
26
|
+
import { AppeekyClient } from "./publish.js";
|
|
27
|
+
const HELP = `open-slideshow ${VERSION}: TikTok slideshows and Instagram carousels, written by your own agent, rendered here.
|
|
28
|
+
|
|
29
|
+
Usage: open-slideshow <command> [options]
|
|
30
|
+
|
|
31
|
+
init [--name N] [--app-store-id ID] set up this folder (not needed in an Appeeky Spec repo)
|
|
32
|
+
agent <claude|codex|cursor> connect your coding agent (skill + MCP)
|
|
33
|
+
info where open-slideshow works and what is here
|
|
34
|
+
brand [--json] [--offline] what your agent knows about the app and brand
|
|
35
|
+
themes [--deck ID] a picture of all 10 themes to pick from
|
|
36
|
+
templates [--theme ID] a picture of the slideshow shapes (tips, story, ranking…)
|
|
37
|
+
new <deck.yaml|deck.json> add a deck from a file
|
|
38
|
+
list decks and their status
|
|
39
|
+
lint <deck> check a deck
|
|
40
|
+
render <deck> render to JPEGs (decks/<deck>/renders)
|
|
41
|
+
image search <query> [--provider P] find photos (openverse, unsplash, pexels)
|
|
42
|
+
image import <path|url> bring an image in
|
|
43
|
+
viral <topic> [--kind K] [--since S] the most liked TikTok slideshows on a topic (Appeeky, $0.01)
|
|
44
|
+
plan [--days N] next post times for enabled channels
|
|
45
|
+
due slots that need a deck now
|
|
46
|
+
preview <deck> [--gif] a phone preview page (renders/preview.html), optionally a GIF
|
|
47
|
+
video <deck> [--seconds N] [--fade N] the slides as an MP4 for Reels and Shorts (needs ffmpeg)
|
|
48
|
+
screenshots import the app's screenshots for screenshot slides
|
|
49
|
+
brand-kit [url] [--apply] brand colours, fonts and logo from the app's website
|
|
50
|
+
license <image-ref> <license> record who may post an image (own, licensed, cc0, by-4.0, unknown…)
|
|
51
|
+
results sync bring in views and likes (Spec posts.jsonl or Appeeky)
|
|
52
|
+
results record <deck> --platform tiktok --views N [--likes N --comments N --shares N --saves N]
|
|
53
|
+
insights [--json] what worked: hooks, templates, themes, times, hook tests, reposts
|
|
54
|
+
ideas [collect] [--json] the idea queue; collect fills it from reviews, comments, listing
|
|
55
|
+
series series and their parts
|
|
56
|
+
publish <deck> --to export|photos|appeeky|postiz|spec-draft [--yes] [--again] [--out DIR] [--when ISO]
|
|
57
|
+
publish --scheduled --to appeeky|postiz|spec-draft [--yes]
|
|
58
|
+
every rendered deck with a time still ahead (for CI)
|
|
59
|
+
mcp run the MCP server (stdio) for your agent
|
|
60
|
+
|
|
61
|
+
Env: APPEEKY_API_KEY (posting through Appeeky, viral search), UNSPLASH_ACCESS_KEY, PEXELS_API_KEY, OPEN_SLIDESHOW_DIR.`;
|
|
62
|
+
const out = (v) => process.stdout.write(`${typeof v === "string" ? v : JSON.stringify(v, null, 2)}\n`);
|
|
63
|
+
function mcpCommand() {
|
|
64
|
+
return { command: "npx", args: ["-y", "@appeeky/open-slideshow", "mcp"] };
|
|
65
|
+
}
|
|
66
|
+
/** Codex and Cursor get the guides through the guide tool, not files next to the skill. */
|
|
67
|
+
function forOtherAgents(skill) {
|
|
68
|
+
return skill
|
|
69
|
+
.replace(/^---[\s\S]*?---\n/, "")
|
|
70
|
+
.replace("Detailed guides live next to this file in `references/`. Read the one you need, or call the `guide` tool with its topic.", "Detailed guides: call the `guide` tool with a topic.");
|
|
71
|
+
}
|
|
72
|
+
function installAgent(agent, root) {
|
|
73
|
+
const mcp = mcpCommand();
|
|
74
|
+
if (agent === "claude") {
|
|
75
|
+
const dir = join(root, ".claude", "skills", "open-slideshow");
|
|
76
|
+
writeAtomic(join(dir, "SKILL.md"), SKILL);
|
|
77
|
+
for (const t of guideTopics())
|
|
78
|
+
writeAtomic(join(dir, "references", `${t}.md`), guideText(t));
|
|
79
|
+
out(`Wrote .claude/skills/open-slideshow (SKILL.md and ${guideTopics().length} guides)\nNow run:\n claude mcp add open-slideshow -- ${mcp.command} ${mcp.args.join(" ")}`);
|
|
80
|
+
}
|
|
81
|
+
else if (agent === "codex") {
|
|
82
|
+
const file = join(root, "AGENTS.md");
|
|
83
|
+
const marker = "<!-- open-slideshow -->";
|
|
84
|
+
const body = forOtherAgents(SKILL);
|
|
85
|
+
const existing = existsSync(file) ? readFileSync(file, "utf8") : "";
|
|
86
|
+
const next = existing.includes(marker) ? existing.replace(new RegExp(`${marker}[\\s\\S]*?${marker}`), `${marker}\n${body}\n${marker}`) : `${existing}${existing ? "\n\n" : ""}${marker}\n${body}\n${marker}\n`;
|
|
87
|
+
writeAtomic(file, next);
|
|
88
|
+
out(`Wrote the open-slideshow section in AGENTS.md\nAdd to ~/.codex/config.toml:\n\n[mcp_servers.open-slideshow]\ncommand = "${mcp.command}"\nargs = [${mcp.args.map((a) => `"${a}"`).join(", ")}]`);
|
|
89
|
+
}
|
|
90
|
+
else if (agent === "cursor") {
|
|
91
|
+
writeAtomic(join(root, ".cursor", "rules", "open-slideshow.mdc"), `---\ndescription: open-slideshow slideshows\nalwaysApply: false\n---\n${forOtherAgents(SKILL)}`);
|
|
92
|
+
const file = join(root, ".cursor", "mcp.json");
|
|
93
|
+
const cfg = existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : {};
|
|
94
|
+
cfg.mcpServers = { ...(cfg.mcpServers ?? {}), "open-slideshow": mcp };
|
|
95
|
+
writeAtomic(file, `${JSON.stringify(cfg, null, 2)}\n`);
|
|
96
|
+
out("Wrote .cursor/rules/open-slideshow.mdc and .cursor/mcp.json");
|
|
97
|
+
}
|
|
98
|
+
else
|
|
99
|
+
throw new UserError("agent: claude, codex or cursor");
|
|
100
|
+
}
|
|
101
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
102
|
+
const [cmd, ...rest] = argv;
|
|
103
|
+
if (!cmd || cmd === "help" || cmd === "--help" || cmd === "-h") {
|
|
104
|
+
out(HELP);
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
if (cmd === "--version" || cmd === "-v") {
|
|
108
|
+
out(VERSION);
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
if (cmd === "mcp") {
|
|
112
|
+
const { startMcp } = await import("./mcp.js");
|
|
113
|
+
await startMcp();
|
|
114
|
+
return -1; // keep running
|
|
115
|
+
}
|
|
116
|
+
const { values: o, positionals: p } = parseArgs({
|
|
117
|
+
args: rest,
|
|
118
|
+
allowPositionals: true,
|
|
119
|
+
options: {
|
|
120
|
+
json: { type: "boolean" },
|
|
121
|
+
offline: { type: "boolean" },
|
|
122
|
+
name: { type: "string" },
|
|
123
|
+
"app-store-id": { type: "string" },
|
|
124
|
+
deck: { type: "string" },
|
|
125
|
+
theme: { type: "string" },
|
|
126
|
+
provider: { type: "string" },
|
|
127
|
+
to: { type: "string" },
|
|
128
|
+
yes: { type: "boolean" },
|
|
129
|
+
again: { type: "boolean" },
|
|
130
|
+
out: { type: "string" },
|
|
131
|
+
when: { type: "string" },
|
|
132
|
+
kind: { type: "string" },
|
|
133
|
+
since: { type: "string" },
|
|
134
|
+
days: { type: "string" },
|
|
135
|
+
scheduled: { type: "boolean" },
|
|
136
|
+
gif: { type: "boolean" },
|
|
137
|
+
seconds: { type: "string" },
|
|
138
|
+
fade: { type: "string" },
|
|
139
|
+
apply: { type: "boolean" },
|
|
140
|
+
platform: { type: "string" },
|
|
141
|
+
views: { type: "string" },
|
|
142
|
+
likes: { type: "string" },
|
|
143
|
+
comments: { type: "string" },
|
|
144
|
+
shares: { type: "string" },
|
|
145
|
+
saves: { type: "string" },
|
|
146
|
+
reach: { type: "string" },
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
const dir = process.env.OPEN_SLIDESHOW_DIR ?? process.cwd();
|
|
150
|
+
try {
|
|
151
|
+
switch (cmd) {
|
|
152
|
+
case "init": {
|
|
153
|
+
const ws = initWorkspace(dir, { app: { name: o.name, app_store_id: o["app-store-id"], country: "us" } });
|
|
154
|
+
out(`open-slideshow is ready in ${ws.dir} (${ws.mode === "spec" ? "Appeeky Spec repo" : "standalone"}).\nNext: open-slideshow agent claude|codex|cursor, then ask your agent for a slideshow.`);
|
|
155
|
+
return 0;
|
|
156
|
+
}
|
|
157
|
+
case "agent":
|
|
158
|
+
installAgent(p[0] ?? "", openWorkspace(dir).root);
|
|
159
|
+
return 0;
|
|
160
|
+
case "info": {
|
|
161
|
+
const ws = openWorkspace(dir);
|
|
162
|
+
out({ mode: ws.mode, root: ws.root, dir: ws.dir, initialized: ws.initialized, app: ws.settings.app, warnings: ws.warnings, decks: listDecks(ws).length, channels: listChannels(ws).length });
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
165
|
+
case "brand": {
|
|
166
|
+
const ctx = await brandContext(openWorkspace(dir), { offline: o.offline });
|
|
167
|
+
out(o.json ? ctx : ctx.markdown);
|
|
168
|
+
return 0;
|
|
169
|
+
}
|
|
170
|
+
case "themes": {
|
|
171
|
+
const g = await themeGallery(openWorkspace(dir), { deck: o.deck });
|
|
172
|
+
out(THEMES.map((t) => `${t.id.padEnd(16)} ${t.description}`).join("\n"));
|
|
173
|
+
out(`\nPicture: ${g.sheet}`);
|
|
174
|
+
return 0;
|
|
175
|
+
}
|
|
176
|
+
case "templates": {
|
|
177
|
+
const g = await templateGallery(openWorkspace(dir), { theme: o.theme });
|
|
178
|
+
out(TEMPLATES.map((t) => `${t.id.padEnd(14)} ${t.description}\n${"".padEnd(14)} ${shapeText(t)}`).join("\n"));
|
|
179
|
+
out(`\nPicture: ${g.sheet}`);
|
|
180
|
+
return 0;
|
|
181
|
+
}
|
|
182
|
+
case "new": {
|
|
183
|
+
const file = p[0];
|
|
184
|
+
if (!file || !existsSync(file))
|
|
185
|
+
throw new UserError("new <deck.yaml|deck.json>");
|
|
186
|
+
const raw = readFileSync(file, "utf8");
|
|
187
|
+
const deck = newDeck(openWorkspace(dir), file.endsWith(".json") ? JSON.parse(raw) : YAML.parse(raw));
|
|
188
|
+
out(`created deck ${deck.id}`);
|
|
189
|
+
return 0;
|
|
190
|
+
}
|
|
191
|
+
case "list":
|
|
192
|
+
out(listDecks(openWorkspace(dir)).map((d) => `${d.id.padEnd(40)} ${d.error ? `ERROR ${d.error.split("\n")[0]}` : `${d.deck.status.padEnd(9)} ${d.deck.theme}`}`).join("\n") || "no decks yet");
|
|
193
|
+
return 0;
|
|
194
|
+
case "lint": {
|
|
195
|
+
const ws = openWorkspace(dir);
|
|
196
|
+
const r = await lintDeck(ws, loadDeck(ws, p[0] ?? ""));
|
|
197
|
+
for (const e of r.errors)
|
|
198
|
+
out(`error ${e.message}`);
|
|
199
|
+
for (const w of r.warnings)
|
|
200
|
+
out(`warning ${w.message}`);
|
|
201
|
+
out(r.ok ? "ok" : `${r.errors.length} error(s)`);
|
|
202
|
+
return r.ok ? 0 : 1;
|
|
203
|
+
}
|
|
204
|
+
case "render": {
|
|
205
|
+
const r = await renderDeckById(openWorkspace(dir), p[0] ?? "");
|
|
206
|
+
for (const e of r.lint.errors)
|
|
207
|
+
out(`error ${e.message}`);
|
|
208
|
+
for (const w of r.lint.warnings)
|
|
209
|
+
out(`warning ${w.message}`);
|
|
210
|
+
out(`rendered ${r.files.length} slides to ${r.dir} (sheet: ${join(r.dir, r.sheet)})`);
|
|
211
|
+
return r.lint.ok ? 0 : 1;
|
|
212
|
+
}
|
|
213
|
+
case "image": {
|
|
214
|
+
const ws = openWorkspace(dir);
|
|
215
|
+
if (p[0] === "search") {
|
|
216
|
+
const hits = await searchImages(p.slice(1).join(" "), { provider: o.provider, orientation: "portrait" });
|
|
217
|
+
out(hits.map((h, i) => `${i + 1}. ${h.url} (${h.license}${h.author ? `, ${h.author}` : ""})`).join("\n") || "nothing found");
|
|
218
|
+
return 0;
|
|
219
|
+
}
|
|
220
|
+
if (p[0] === "import" && p[1]) {
|
|
221
|
+
mkdirSync(join(ws.dir, "images"), { recursive: true });
|
|
222
|
+
const m = /^https:\/\//.test(p[1]) ? await importImageFromUrl(ws, p[1]) : await importImageFromFile(ws, resolve(p[1]));
|
|
223
|
+
out(`imported as ${m.ref} (${m.width}×${m.height})`);
|
|
224
|
+
return 0;
|
|
225
|
+
}
|
|
226
|
+
throw new UserError("image search <query> | image import <path|url>");
|
|
227
|
+
}
|
|
228
|
+
case "viral": {
|
|
229
|
+
if (!p.length)
|
|
230
|
+
throw new UserError("viral <topic> [--kind slideshow|video|any] [--since week|month|quarter|half|any]");
|
|
231
|
+
const posts = await viralSearch(p.join(" "), { kind: o.kind ?? "slideshow", since: o.since ?? "quarter" });
|
|
232
|
+
out(viralLines(posts).join("\n") || "nothing found");
|
|
233
|
+
return 0;
|
|
234
|
+
}
|
|
235
|
+
case "plan": {
|
|
236
|
+
const ws = openWorkspace(dir);
|
|
237
|
+
const chans = listChannels(ws).filter((c) => c.channel?.enabled);
|
|
238
|
+
if (!chans.length)
|
|
239
|
+
throw new UserError("no enabled channels");
|
|
240
|
+
const slots = savePlan(ws, chans.flatMap((c) => planSlots(c.channel, new Date(), Number(o.days ?? 7))));
|
|
241
|
+
out(slots.map((s) => `${s.at} ${s.channel.padEnd(20)} ${s.deck ?? "(needs a deck)"}${s.note ? ` ${s.note}` : ""}`).join("\n"));
|
|
242
|
+
return 0;
|
|
243
|
+
}
|
|
244
|
+
case "due": {
|
|
245
|
+
const due = dueSlots(openWorkspace(dir));
|
|
246
|
+
out(due.length ? due.map((s) => `${s.at} ${s.channel}`).join("\n") : "nothing due");
|
|
247
|
+
return 0;
|
|
248
|
+
}
|
|
249
|
+
case "preview": {
|
|
250
|
+
const r = await previewDeck(openWorkspace(dir), p[0] ?? "", { gif: o.gif });
|
|
251
|
+
out(`open ${r.html}${r.gif ? `\ngif: ${r.gif}` : ""}`);
|
|
252
|
+
return 0;
|
|
253
|
+
}
|
|
254
|
+
case "video": {
|
|
255
|
+
const r = await renderVideo(openWorkspace(dir), p[0] ?? "", { seconds: o.seconds ? Number(o.seconds) : undefined, fade: o.fade ? Number(o.fade) : undefined });
|
|
256
|
+
out(`${r.file} (${r.seconds}s)`);
|
|
257
|
+
return 0;
|
|
258
|
+
}
|
|
259
|
+
case "screenshots": {
|
|
260
|
+
const r = await appScreenshots(openWorkspace(dir));
|
|
261
|
+
out(`from ${r.source}:\n${r.images.map((m) => `${m.ref} ${m.width}×${m.height}`).join("\n")}\nUse a ref as the image of a slide with kind: screenshot.`);
|
|
262
|
+
return 0;
|
|
263
|
+
}
|
|
264
|
+
case "brand-kit": {
|
|
265
|
+
const r = await brandKit(openWorkspace(dir), { url: p[0], apply: o.apply });
|
|
266
|
+
out(o.json ? r : `${r.source}\ncolours: bg ${r.colors.bg}, text ${r.colors.fg}, accent ${r.colors.accent}\nfound: ${r.colors_found.join(" ")}${r.fonts.length ? `\nfonts: ${r.fonts.join(", ")}` : ""}${r.theme ? `\ntheme: ${r.theme.theme} (${r.theme.why})` : ""}${r.logo ? `\nlogo: ${r.logo}` : ""}\n${r.notes.map((n) => `- ${n}`).join("\n")}\n${r.applied ? "saved" : "not saved: add --apply to save the colours and the logo"}`);
|
|
267
|
+
return 0;
|
|
268
|
+
}
|
|
269
|
+
case "license": {
|
|
270
|
+
if (!p[0] || !p[1])
|
|
271
|
+
throw new UserError("license <image-ref> <own|licensed|cc0|pdm|by-4.0|…|unknown>");
|
|
272
|
+
const m = setImageLicense(openWorkspace(dir), p[0], p[1]);
|
|
273
|
+
out(`${m.ref}: ${m.license}`);
|
|
274
|
+
return 0;
|
|
275
|
+
}
|
|
276
|
+
case "results": {
|
|
277
|
+
const ws = openWorkspace(dir);
|
|
278
|
+
if (p[0] === "sync") {
|
|
279
|
+
const client = process.env.APPEEKY_API_KEY ? new AppeekyClient() : undefined;
|
|
280
|
+
const r = await syncResults(ws, client ? (id) => client.analytics(id) : undefined);
|
|
281
|
+
out(o.json ? r : [...r.updated.map((u) => `${u.deck} ${u.platform ?? ""} ${Object.entries(u.metrics).map(([k, v]) => `${k} ${v}`).join(", ")}`), ...r.skipped.map((x) => `${x.deck} skipped: ${x.why}`)].join("\n") || "nothing published yet");
|
|
282
|
+
return 0;
|
|
283
|
+
}
|
|
284
|
+
if (p[0] === "record" && p[1]) {
|
|
285
|
+
const num = (v) => (v === undefined ? undefined : Number(v));
|
|
286
|
+
const d = recordResult(ws, p[1], { platform: o.platform, views: num(o.views), likes: num(o.likes), comments: num(o.comments), shares: num(o.shares), saves: num(o.saves), reach: num(o.reach) });
|
|
287
|
+
out(`saved for ${d.id}`);
|
|
288
|
+
return 0;
|
|
289
|
+
}
|
|
290
|
+
throw new UserError("results sync | results record <deck> --platform tiktok --views N …");
|
|
291
|
+
}
|
|
292
|
+
case "insights": {
|
|
293
|
+
const r = insights(openWorkspace(dir));
|
|
294
|
+
out(o.json ? r : r.markdown);
|
|
295
|
+
return 0;
|
|
296
|
+
}
|
|
297
|
+
case "ideas": {
|
|
298
|
+
const ws = openWorkspace(dir);
|
|
299
|
+
if (p[0] === "collect") {
|
|
300
|
+
const r = await collectIdeas(ws, { offline: o.offline });
|
|
301
|
+
out(o.json ? r : r.added.map((i) => `+ ${i.id} [${i.source}] ${i.text}`).join("\n") || `nothing new (${r.found} found, all already in the queue)`);
|
|
302
|
+
return 0;
|
|
303
|
+
}
|
|
304
|
+
const ideas = readIdeas(ws);
|
|
305
|
+
out(o.json ? ideas : ideas.map((i) => `${i.id} ${i.status.padEnd(7)} [${i.source}] ${i.text}`).join("\n") || "no ideas yet: open-slideshow ideas collect");
|
|
306
|
+
return 0;
|
|
307
|
+
}
|
|
308
|
+
case "series": {
|
|
309
|
+
const r = listSeries(openWorkspace(dir));
|
|
310
|
+
out(r.map((s) => `${s.id}\n${s.parts.map((x) => ` part ${x.part}${x.of ? `/${x.of}` : ""} ${x.deck.padEnd(36)} ${x.status}${x.when ? ` ${x.when}` : ""}`).join("\n")}`).join("\n") || "no series");
|
|
311
|
+
return 0;
|
|
312
|
+
}
|
|
313
|
+
case "publish": {
|
|
314
|
+
const provider = (o.to ?? o.provider);
|
|
315
|
+
if (!provider || !["export", "photos", "appeeky", "postiz", "spec-draft"].includes(provider))
|
|
316
|
+
throw new UserError("publish <deck> --to export|photos|appeeky|postiz|spec-draft");
|
|
317
|
+
if (o.scheduled) {
|
|
318
|
+
// For CI: the decks a person already approved (merged) with a time still ahead. Never "post now".
|
|
319
|
+
if (p[0])
|
|
320
|
+
throw new UserError("publish --scheduled takes no deck; it publishes every rendered deck with a time");
|
|
321
|
+
if (!["appeeky", "postiz", "spec-draft"].includes(provider))
|
|
322
|
+
throw new UserError("publish --scheduled works with --to appeeky, postiz or spec-draft");
|
|
323
|
+
const ws = openWorkspace(dir);
|
|
324
|
+
const soon = Date.now() + 2 * 60_000;
|
|
325
|
+
const ready = listDecks(ws).filter((d) => d.deck && d.deck.status === "rendered" && d.deck.when && Date.parse(d.deck.when) > soon);
|
|
326
|
+
if (!ready.length) {
|
|
327
|
+
out("nothing to schedule");
|
|
328
|
+
return 0;
|
|
329
|
+
}
|
|
330
|
+
let failed = 0;
|
|
331
|
+
for (const d of ready) {
|
|
332
|
+
try {
|
|
333
|
+
const r = await publishDeck(ws, d.id, { provider, confirm: o.yes });
|
|
334
|
+
out(`${d.id}: ${r.done ? r.message : `would schedule for ${d.deck.when} (add --yes)`}`);
|
|
335
|
+
}
|
|
336
|
+
catch (e) {
|
|
337
|
+
failed++;
|
|
338
|
+
process.stderr.write(`${d.id}: ${e.message}\n`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return failed ? 1 : 0;
|
|
342
|
+
}
|
|
343
|
+
const r = await publishDeck(openWorkspace(dir), p[0] ?? "", { provider, confirm: o.yes, again: o.again, out: o.out ? resolve(o.out) : undefined, when: o.when });
|
|
344
|
+
out(r.done ? r.message : `${JSON.stringify(r.preview, null, 2)}\n${r.message.replace("call again with confirm", "add --yes")}`);
|
|
345
|
+
return 0;
|
|
346
|
+
}
|
|
347
|
+
default:
|
|
348
|
+
throw new UserError(`unknown command "${cmd}"\n\n${HELP}`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
catch (e) {
|
|
352
|
+
process.stderr.write(`${e instanceof UserError ? e.message : e.stack ?? String(e)}\n`);
|
|
353
|
+
return 1;
|
|
354
|
+
}
|
|
355
|
+
}
|
package/dist/decks.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type Deck, type DeckInput, type Slide } from "./schema.js";
|
|
2
|
+
import { type RenderResult } from "./render.js";
|
|
3
|
+
import { type LintResult } from "./lint.js";
|
|
4
|
+
import { type Workspace } from "./workspace.js";
|
|
5
|
+
export interface Manifest {
|
|
6
|
+
deck: string;
|
|
7
|
+
hash: string;
|
|
8
|
+
files: string[];
|
|
9
|
+
size: Deck["size"];
|
|
10
|
+
theme: string;
|
|
11
|
+
rendered_at: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const manifestFile: (ws: Workspace, id: string) => string;
|
|
14
|
+
export declare const readManifest: (ws: Workspace, id: string) => Manifest | null;
|
|
15
|
+
export declare function newDeck(ws: Workspace, input: Omit<DeckInput, "id"> & {
|
|
16
|
+
id?: string;
|
|
17
|
+
}, opts?: {
|
|
18
|
+
overwrite?: boolean;
|
|
19
|
+
}): Deck;
|
|
20
|
+
export interface DeckPatch extends Partial<Omit<Deck, "id" | "version" | "published" | "status" | "slides">> {
|
|
21
|
+
slides?: Slide[];
|
|
22
|
+
/** Changes to single slides by index (0-based), merged into the slide. */
|
|
23
|
+
slide_edits?: {
|
|
24
|
+
index: number;
|
|
25
|
+
set: Partial<Slide>;
|
|
26
|
+
}[];
|
|
27
|
+
insert?: {
|
|
28
|
+
index: number;
|
|
29
|
+
slide: Slide;
|
|
30
|
+
}[];
|
|
31
|
+
remove?: number[];
|
|
32
|
+
move?: {
|
|
33
|
+
from: number;
|
|
34
|
+
to: number;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export declare function updateDeck(ws: Workspace, id: string, patch: DeckPatch): Deck;
|
|
38
|
+
export interface RenderOutcome extends RenderResult {
|
|
39
|
+
dir: string;
|
|
40
|
+
lint: LintResult;
|
|
41
|
+
}
|
|
42
|
+
export declare function renderDeckById(ws: Workspace, id: string): Promise<RenderOutcome>;
|
|
43
|
+
/** The renders on disk, only if they match the deck as it is now. */
|
|
44
|
+
export declare function freshRenders(ws: Workspace, deck: Deck): Manifest;
|