@appeeky/open-slideshow 0.1.0 → 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.
Files changed (55) hide show
  1. package/README.md +93 -23
  2. package/dist/bin.js +0 -0
  3. package/dist/brand.d.ts +2 -0
  4. package/dist/brand.js +36 -19
  5. package/dist/brandkit.d.ts +50 -0
  6. package/dist/brandkit.js +212 -0
  7. package/dist/cli.js +94 -0
  8. package/dist/decks.js +11 -1
  9. package/dist/ideas.d.ts +50 -0
  10. package/dist/ideas.js +146 -0
  11. package/dist/images.d.ts +15 -2
  12. package/dist/images.js +23 -5
  13. package/dist/index.d.ts +9 -0
  14. package/dist/index.js +9 -0
  15. package/dist/lint.d.ts +5 -2
  16. package/dist/lint.js +18 -2
  17. package/dist/mcp.js +72 -2
  18. package/dist/preview.d.ts +18 -0
  19. package/dist/preview.js +96 -0
  20. package/dist/publish.d.ts +5 -0
  21. package/dist/publish.js +6 -1
  22. package/dist/readability.d.ts +19 -0
  23. package/dist/readability.js +42 -0
  24. package/dist/render.d.ts +21 -2
  25. package/dist/render.js +143 -11
  26. package/dist/results.d.ts +89 -0
  27. package/dist/results.js +252 -0
  28. package/dist/schema.d.ts +166 -11
  29. package/dist/schema.js +38 -1
  30. package/dist/screenshots.d.ts +18 -0
  31. package/dist/screenshots.js +69 -0
  32. package/dist/templates.d.ts +4 -1
  33. package/dist/templates.js +145 -0
  34. package/dist/text.js +2 -1
  35. package/dist/variants.d.ts +48 -0
  36. package/dist/variants.js +175 -0
  37. package/dist/version.d.ts +1 -1
  38. package/dist/version.js +1 -1
  39. package/dist/video.d.ts +22 -0
  40. package/dist/video.js +59 -0
  41. package/dist/workspace.d.ts +5 -0
  42. package/dist/workspace.js +16 -0
  43. package/package.json +1 -1
  44. package/skills/open-slideshow/SKILL.md +16 -3
  45. package/skills/open-slideshow/references/brand.md +10 -0
  46. package/skills/open-slideshow/references/ideas.md +23 -0
  47. package/skills/open-slideshow/references/images.md +9 -1
  48. package/skills/open-slideshow/references/languages.md +10 -0
  49. package/skills/open-slideshow/references/results.md +47 -0
  50. package/skills/open-slideshow/references/review.md +8 -1
  51. package/skills/open-slideshow/references/screenshots.md +26 -0
  52. package/skills/open-slideshow/references/series.md +20 -0
  53. package/skills/open-slideshow/references/templates.md +37 -0
  54. package/skills/open-slideshow/references/troubleshooting.md +11 -1
  55. package/skills/open-slideshow/references/video.md +18 -0
package/dist/cli.js CHANGED
@@ -15,6 +15,15 @@ import { THEMES } from "./themes.js";
15
15
  import { TEMPLATES, shapeText } from "./templates.js";
16
16
  import { initWorkspace, listChannels, listDecks, loadDeck, openWorkspace, UserError, writeAtomic } from "./workspace.js";
17
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";
18
27
  const HELP = `open-slideshow ${VERSION}: TikTok slideshows and Instagram carousels, written by your own agent, rendered here.
19
28
 
20
29
  Usage: open-slideshow <command> [options]
@@ -34,6 +43,16 @@ Usage: open-slideshow <command> [options]
34
43
  viral <topic> [--kind K] [--since S] the most liked TikTok slideshows on a topic (Appeeky, $0.01)
35
44
  plan [--days N] next post times for enabled channels
36
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
37
56
  publish <deck> --to export|photos|appeeky|postiz|spec-draft [--yes] [--again] [--out DIR] [--when ISO]
38
57
  publish --scheduled --to appeeky|postiz|spec-draft [--yes]
39
58
  every rendered deck with a time still ahead (for CI)
@@ -114,6 +133,17 @@ export async function main(argv = process.argv.slice(2)) {
114
133
  since: { type: "string" },
115
134
  days: { type: "string" },
116
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" },
117
147
  },
118
148
  });
119
149
  const dir = process.env.OPEN_SLIDESHOW_DIR ?? process.cwd();
@@ -216,6 +246,70 @@ export async function main(argv = process.argv.slice(2)) {
216
246
  out(due.length ? due.map((s) => `${s.at} ${s.channel}`).join("\n") : "nothing due");
217
247
  return 0;
218
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
+ }
219
313
  case "publish": {
220
314
  const provider = (o.to ?? o.provider);
221
315
  if (!provider || !["export", "photos", "appeeky", "postiz", "spec-draft"].includes(provider))
package/dist/decks.js CHANGED
@@ -2,7 +2,8 @@ import { existsSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { deckSchema, slideSchema } from "./schema.js";
4
4
  import { renderDeck, renderHash } from "./render.js";
5
- import { lintDeck, renderContext } from "./lint.js";
5
+ import { lintDeck, platformsOf, renderContext } from "./lint.js";
6
+ import { tiktokIssues } from "./readability.js";
6
7
  import { getTheme } from "./themes.js";
7
8
  import { deckExists, loadDeck, parseWith, readJson, rendersDir, saveDeck, uniqueDeckId, UserError, writeAtomic } from "./workspace.js";
8
9
  import { plainText } from "./text.js";
@@ -73,6 +74,15 @@ export async function renderDeckById(ws, id) {
73
74
  writeAtomic(manifestFile(ws, id), JSON.stringify(manifest, null, 2));
74
75
  if (deck.status === "draft")
75
76
  saveDeck(ws, { ...deck, status: "rendered" });
77
+ // What only a real render can see (the photo behind the words, images that failed to load),
78
+ // and TikTok's buttons checked against the lines as they were drawn.
79
+ const drawn = platformsOf(deck).has("tiktok") ? result.lines.flatMap((l, i) => tiktokIssues(l, deck.size, i)) : [];
80
+ for (const i of [...result.issues, ...drawn]) {
81
+ const list = i.level === "error" ? lint.errors : lint.warnings;
82
+ if (![...lint.errors, ...lint.warnings].some((x) => x.code === i.code && x.slide === i.slide))
83
+ list.push({ level: i.level, code: i.code, message: i.message, slide: i.slide });
84
+ }
85
+ lint.ok = lint.errors.length === 0;
76
86
  return { ...result, dir, lint };
77
87
  }
78
88
  /** The renders on disk, only if they match the deck as it is now. */
@@ -0,0 +1,50 @@
1
+ import { z } from "zod";
2
+ import { type Workspace } from "./workspace.js";
3
+ export declare const ideaSchema: z.ZodObject<{
4
+ id: z.ZodString;
5
+ text: z.ZodString;
6
+ /** Where it came from: review, comment, listing, playbook, channel, viral, user. */
7
+ source: z.ZodString;
8
+ /** The words behind it (a review, a comment), so the slides can stay true to them. */
9
+ evidence: z.ZodOptional<z.ZodString>;
10
+ status: z.ZodDefault<z.ZodEnum<["new", "used", "skipped"]>>;
11
+ deck: z.ZodOptional<z.ZodString>;
12
+ added_at: z.ZodString;
13
+ }, "strict", z.ZodTypeAny, {
14
+ status: "new" | "used" | "skipped";
15
+ text: string;
16
+ source: string;
17
+ id: string;
18
+ added_at: string;
19
+ deck?: string | undefined;
20
+ evidence?: string | undefined;
21
+ }, {
22
+ text: string;
23
+ source: string;
24
+ id: string;
25
+ added_at: string;
26
+ status?: "new" | "used" | "skipped" | undefined;
27
+ deck?: string | undefined;
28
+ evidence?: string | undefined;
29
+ }>;
30
+ export type Idea = z.infer<typeof ideaSchema>;
31
+ export declare const ideasFile: (ws: Workspace) => string;
32
+ export declare function readIdeas(ws: Workspace): Idea[];
33
+ /** Adds ideas that are not in the queue yet (same words = same idea). Returns the ones added. */
34
+ export declare function addIdeas(ws: Workspace, fresh: Omit<Idea, "id" | "status" | "added_at">[], now?: Date, max?: number): Idea[];
35
+ export declare function updateIdea(ws: Workspace, id: string, patch: {
36
+ status?: Idea["status"];
37
+ deck?: string;
38
+ }): Idea;
39
+ /**
40
+ * Turns what the repo and the store already know into slideshow ideas: questions people keep
41
+ * asking, what reviewers love or miss, the listing's own features, playbook wins and channel
42
+ * topics not used yet. Nothing is posted or sent anywhere.
43
+ */
44
+ export declare function collectIdeas(ws: Workspace, opts?: {
45
+ offline?: boolean;
46
+ limit?: number;
47
+ }): Promise<{
48
+ added: Idea[];
49
+ found: number;
50
+ }>;
package/dist/ideas.js ADDED
@@ -0,0 +1,146 @@
1
+ import { createHash } from "node:crypto";
2
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import YAML from "yaml";
5
+ import { z } from "zod";
6
+ import { normalizeHook, specListing } from "./brand.js";
7
+ import { listChannels, listDecks, parseWith, readJsonl, UserError, writeAtomic } from "./workspace.js";
8
+ export const ideaSchema = z
9
+ .object({
10
+ id: z.string().min(1).max(64),
11
+ text: z.string().min(1).max(400),
12
+ /** Where it came from: review, comment, listing, playbook, channel, viral, user. */
13
+ source: z.string().min(1).max(40),
14
+ /** The words behind it (a review, a comment), so the slides can stay true to them. */
15
+ evidence: z.string().max(600).optional(),
16
+ status: z.enum(["new", "used", "skipped"]).default("new"),
17
+ deck: z.string().optional(),
18
+ added_at: z.string(),
19
+ })
20
+ .strict();
21
+ const fileSchema = z.object({ ideas: z.array(ideaSchema).default([]) }).strict();
22
+ export const ideasFile = (ws) => join(ws.dir, "ideas.yaml");
23
+ export function readIdeas(ws) {
24
+ const f = ideasFile(ws);
25
+ if (!existsSync(f))
26
+ return [];
27
+ return parseWith(fileSchema, YAML.parse(readFileSync(f, "utf8")) ?? {}, f).ideas;
28
+ }
29
+ function saveIdeas(ws, ideas) {
30
+ writeAtomic(ideasFile(ws), `# Slideshow ideas: open-slideshow adds them (ideas_collect), you or your agent pick one, it becomes a deck.\n${YAML.stringify({ ideas }, { lineWidth: 0 })}`);
31
+ }
32
+ const ideaId = (text) => createHash("sha256").update(normalizeHook(text)).digest("hex").slice(0, 10);
33
+ /** Adds ideas that are not in the queue yet (same words = same idea). Returns the ones added. */
34
+ export function addIdeas(ws, fresh, now = new Date(), max = Infinity) {
35
+ const ideas = readIdeas(ws);
36
+ const have = new Set(ideas.map((i) => i.id));
37
+ const added = [];
38
+ for (const f of fresh) {
39
+ if (added.length >= max)
40
+ break;
41
+ const id = ideaId(f.text);
42
+ if (have.has(id))
43
+ continue;
44
+ have.add(id);
45
+ const idea = ideaSchema.parse({ ...f, text: f.text.slice(0, 400), ...(f.evidence ? { evidence: f.evidence.slice(0, 600) } : {}), id, status: "new", added_at: now.toISOString() });
46
+ ideas.push(idea);
47
+ added.push(idea);
48
+ }
49
+ if (added.length)
50
+ saveIdeas(ws, ideas);
51
+ return added;
52
+ }
53
+ export function updateIdea(ws, id, patch) {
54
+ const ideas = readIdeas(ws);
55
+ const i = ideas.find((x) => x.id === id);
56
+ if (!i)
57
+ throw new UserError(`no idea ${id}; ideas_list shows them`);
58
+ Object.assign(i, patch);
59
+ saveIdeas(ws, ideas);
60
+ return i;
61
+ }
62
+ const clip = (s, n = 220) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);
63
+ /** Reviews Spec pulled: appeeky/reviews/<store>/<YYYY-MM>.jsonl. */
64
+ function specReviews(ws) {
65
+ const dir = ws.spec?.reviews_dir;
66
+ if (!dir || !existsSync(dir))
67
+ return [];
68
+ const out = [];
69
+ for (const store of readdirSync(dir)) {
70
+ const sd = join(dir, store);
71
+ if (!/^(app-store|google-play)$/.test(store) || !existsSync(sd))
72
+ continue;
73
+ for (const f of readdirSync(sd).filter((f) => /^\d{4}-\d{2}\.jsonl$/.test(f)).sort().reverse().slice(0, 3))
74
+ out.push(...readJsonl(join(sd, f)));
75
+ }
76
+ return out;
77
+ }
78
+ /** Recent App Store reviews from Apple's public feed, for a workspace outside Spec. */
79
+ async function appStoreReviews(id, country) {
80
+ try {
81
+ const res = await fetch(`https://itunes.apple.com/${encodeURIComponent(country)}/rss/customerreviews/id=${encodeURIComponent(id)}/sortBy=mostRecent/json`, { signal: AbortSignal.timeout(10_000) });
82
+ if (!res.ok)
83
+ return [];
84
+ const data = (await res.json());
85
+ return (data.feed?.entry ?? []).map((e) => ({ title: e.title?.label, body: e.content?.label, rating: Number(e["im:rating"]?.label ?? 0), date: e.updated?.label }));
86
+ }
87
+ catch {
88
+ return [];
89
+ }
90
+ }
91
+ const QUESTION = /\?|\b(how do|how can|does it|can it|is there|what about|why)\b/i;
92
+ const COMPLAINT = /\b(cancel|refund|charged|scam|rip ?off|subscription trap|crash(es|ed)?|bug(gy)?|broken|doesn.?t work|waste)\b/i;
93
+ const WISH = /\b(wish|please add|would love|need(s)? a|missing|feature request|should have|add an? )\b/i;
94
+ /**
95
+ * Turns what the repo and the store already know into slideshow ideas: questions people keep
96
+ * asking, what reviewers love or miss, the listing's own features, playbook wins and channel
97
+ * topics not used yet. Nothing is posted or sent anywhere.
98
+ */
99
+ export async function collectIdeas(ws, opts = {}) {
100
+ const found = [];
101
+ const limit = opts.limit ?? 20;
102
+ const reviews = ws.spec ? specReviews(ws) : ws.settings.app.app_store_id && !opts.offline ? await appStoreReviews(ws.settings.app.app_store_id, ws.settings.app.country) : [];
103
+ for (const r of reviews) {
104
+ const words = `${r.title ?? ""} ${r.body ?? ""}`.trim();
105
+ if (words.length < 25 || COMPLAINT.test(words))
106
+ continue;
107
+ // A short title ("Try it!") says nothing; the first sentence of the review does.
108
+ const gist = clip((r.title ?? "").length >= 18 ? r.title : (r.body ?? r.title ?? "").split(/(?<=[.!?])\s/)[0], 90);
109
+ const wish = `${r.title ?? ""}. ${r.body ?? ""}`.split(/(?<=[.!?])\s+/).find((x) => WISH.test(x));
110
+ if (wish)
111
+ found.push({ text: `Answer a wish from reviews: ${clip(wish.trim(), 110)}`, source: "review", evidence: clip(words, 500) });
112
+ else if ((r.rating ?? 0) >= 5 && words.length > 60)
113
+ found.push({ text: `What one user loves, told as a story: ${gist}`, source: "review", evidence: clip(words, 500) });
114
+ }
115
+ if (ws.spec?.comments_file && existsSync(ws.spec.comments_file)) {
116
+ for (const c of readJsonl(ws.spec.comments_file)) {
117
+ if (c.own || c.reply || !c.text || c.text.length < 15 || !QUESTION.test(c.text))
118
+ continue;
119
+ found.push({ text: `A slideshow that answers: "${clip(c.text, 120)}"`, source: "comment", evidence: clip(c.text, 500) });
120
+ }
121
+ }
122
+ const listing = ws.mode === "spec" ? specListing(ws) : undefined;
123
+ if (listing) {
124
+ for (const line of listing.split("\n")) {
125
+ const m = line.match(/^\s*[•\-*]\s+(.{8,120})$/);
126
+ if (m)
127
+ found.push({ text: `Show the feature in use (with a screenshot slide): ${m[1].trim()}`, source: "listing", evidence: m[1].trim() });
128
+ }
129
+ }
130
+ if (ws.spec?.playbook && existsSync(ws.spec.playbook)) {
131
+ for (const line of readFileSync(ws.spec.playbook, "utf8").split("\n")) {
132
+ if (/→.*\bwon\b/i.test(line))
133
+ found.push({ text: `Turn a win into a post: ${clip(line.replace(/^[-*]\s*/, ""), 160)}`, source: "playbook", evidence: clip(line, 500) });
134
+ }
135
+ }
136
+ const usedTopics = new Set(listDecks(ws).map((d) => normalizeHook(d.deck?.topic ?? "")).filter(Boolean));
137
+ for (const c of listChannels(ws))
138
+ for (const t of c.channel?.content.topics ?? [])
139
+ if (!usedTopics.has(normalizeHook(t)))
140
+ found.push({ text: `${c.id}: ${t}`, source: "channel" });
141
+ // Questions and wishes first: they come from real people.
142
+ const order = ["comment", "review", "listing", "playbook", "channel"];
143
+ found.sort((a, b) => order.indexOf(a.source) - order.indexOf(b.source));
144
+ const added = addIdeas(ws, found, new Date(), limit);
145
+ return { added, found: found.length };
146
+ }
package/dist/images.d.ts CHANGED
@@ -18,12 +18,25 @@ export declare function isPrivateAddress(ip: string): boolean;
18
18
  export declare function assertPublicUrl(raw: string): Promise<URL>;
19
19
  export declare function download(raw: string, retried?: boolean): Promise<Buffer>;
20
20
  /** Decodes, turns upright, strips metadata (GPS too) and stores the image as JPEG under images/. */
21
- export declare function storeImage(ws: Workspace, input: Buffer, meta: Omit<ImageMeta, "ref" | "width" | "height" | "imported_at">): Promise<ImageMeta>;
22
- export declare function importImageFromUrl(ws: Workspace, url: string, meta?: Partial<Omit<ImageMeta, "ref" | "width" | "height" | "imported_at">>): Promise<ImageMeta>;
21
+ export declare function storeImage(ws: Workspace, input: Buffer, meta: Omit<ImageMeta, "ref" | "width" | "height" | "imported_at">, opts?: {
22
+ minSize?: number;
23
+ }): Promise<ImageMeta>;
24
+ export declare function importImageFromUrl(ws: Workspace, url: string, meta?: Partial<Omit<ImageMeta, "ref" | "width" | "height" | "imported_at">>, opts?: {
25
+ minSize?: number;
26
+ }): Promise<ImageMeta>;
23
27
  /** A file the user has. Paths outside the workspace are fine to read (it is the user's machine), never to reference. */
24
28
  export declare function importImageFromFile(ws: Workspace, path: string, meta?: Partial<Omit<ImageMeta, "ref" | "width" | "height" | "imported_at">>): Promise<ImageMeta>;
25
29
  export declare function listImages(ws: Workspace): ImageMeta[];
26
30
  export declare function imageMeta(ws: Workspace, ref: string): ImageMeta | null;
31
+ /** Licenses people can record with image_license: their own, bought or licensed, or an open license. */
32
+ export declare const LICENSES: readonly ["own", "licensed", "cc0", "pdm", "by-4.0", "by-3.0", "by-2.0", "unsplash", "pexels", "unknown"];
33
+ /** Whether someone said the image may be posted: anything but unknown. */
34
+ export declare function licenseKnown(m: ImageMeta): boolean;
35
+ /** Records who may post an image and under which license; the image itself does not change. */
36
+ export declare function setImageLicense(ws: Workspace, ref: string, license: string, extra?: {
37
+ author?: string;
38
+ note?: string;
39
+ }): ImageMeta;
27
40
  /** Licenses that need the author named somewhere: we put it in credits.txt and the caption suggestion. */
28
41
  export declare function needsAttribution(m: ImageMeta | null): boolean;
29
42
  export interface ImageHit {
package/dist/images.js CHANGED
@@ -91,7 +91,7 @@ export async function download(raw, retried = false) {
91
91
  }
92
92
  // ---------- storing ----------
93
93
  /** Decodes, turns upright, strips metadata (GPS too) and stores the image as JPEG under images/. */
94
- export async function storeImage(ws, input, meta) {
94
+ export async function storeImage(ws, input, meta, opts = {}) {
95
95
  let info;
96
96
  try {
97
97
  info = await sharp(input, { limitInputPixels: MAX_PIXELS }).metadata();
@@ -101,8 +101,9 @@ export async function storeImage(ws, input, meta) {
101
101
  }
102
102
  if (!info.format || !ALLOWED_FORMATS.has(info.format))
103
103
  throw new UserError(`image format ${info.format ?? "unknown"} is not accepted (use JPEG, PNG, WebP, AVIF or HEIC)`);
104
- if ((info.width ?? 0) < 200 || (info.height ?? 0) < 200)
105
- throw new UserError(`image is too small (${info.width}×${info.height}); use at least 600 px`);
104
+ const min = opts.minSize ?? 200;
105
+ if ((info.width ?? 0) < min || (info.height ?? 0) < min)
106
+ throw new UserError(`image is too small (${info.width}×${info.height}); use at least 200 px, and 600 px or more for a photo behind the words`);
106
107
  const out = await sharp(input, { limitInputPixels: MAX_PIXELS, animated: false })
107
108
  .rotate()
108
109
  .resize({ width: 2160, height: 2700, fit: "inside", withoutEnlargement: true })
@@ -121,9 +122,9 @@ export async function storeImage(ws, input, meta) {
121
122
  writeAtomic(metaFile, JSON.stringify(full, null, 2));
122
123
  return readJson(metaFile, full);
123
124
  }
124
- export async function importImageFromUrl(ws, url, meta = {}) {
125
+ export async function importImageFromUrl(ws, url, meta = {}, opts = {}) {
125
126
  const buf = await download(url);
126
- return storeImage(ws, buf, { source: meta.source ?? "url", license: meta.license ?? "unknown", url, ...meta });
127
+ return storeImage(ws, buf, { source: meta.source ?? "url", license: meta.license ?? "unknown", url, ...meta }, opts);
127
128
  }
128
129
  /** A file the user has. Paths outside the workspace are fine to read (it is the user's machine), never to reference. */
129
130
  export async function importImageFromFile(ws, path, meta = {}) {
@@ -153,6 +154,23 @@ export function imageMeta(ws, ref) {
153
154
  return null;
154
155
  return readJson(join(imagesDir(ws), `${m[1]}.json`), null);
155
156
  }
157
+ /** Licenses people can record with image_license: their own, bought or licensed, or an open license. */
158
+ export const LICENSES = ["own", "licensed", "cc0", "pdm", "by-4.0", "by-3.0", "by-2.0", "unsplash", "pexels", "unknown"];
159
+ /** Whether someone said the image may be posted: anything but unknown. */
160
+ export function licenseKnown(m) {
161
+ return !!m.license && m.license !== "unknown";
162
+ }
163
+ /** Records who may post an image and under which license; the image itself does not change. */
164
+ export function setImageLicense(ws, ref, license, extra = {}) {
165
+ const m = imageMeta(ws, ref);
166
+ if (!m)
167
+ throw new UserError(`no image ${ref}; image_list shows them`);
168
+ if (!LICENSES.includes(license))
169
+ throw new UserError(`license: one of ${LICENSES.join(", ")}`);
170
+ const next = { ...m, license, ...(extra.author ? { author: extra.author } : {}), ...(extra.note ? { note: extra.note } : {}) };
171
+ writeAtomic(join(imagesDir(ws), `${m.ref.replace(/\.jpg$/, "")}.json`), JSON.stringify(next, null, 2));
172
+ return next;
173
+ }
156
174
  /** Licenses that need the author named somewhere: we put it in credits.txt and the caption suggestion. */
157
175
  export function needsAttribution(m) {
158
176
  return !!m && /^(by|cc-by|cc by)/i.test(m.license);
package/dist/index.d.ts CHANGED
@@ -10,3 +10,12 @@ export { publishDeck } from "./publish.js";
10
10
  export { planSlots, dueSlots } from "./schedule.js";
11
11
  export { createServer } from "./mcp.js";
12
12
  export { SKILL } from "./skill.js";
13
+ export { syncResults, recordResult, insights, hookTraits, experimentVerdict } from "./results.js";
14
+ export { hookTest, seriesNext, listSeries, translateDeck, repostDeck } from "./variants.js";
15
+ export { collectIdeas, readIdeas, addIdeas, updateIdea } from "./ideas.js";
16
+ export { brandKit } from "./brandkit.js";
17
+ export { appScreenshots } from "./screenshots.js";
18
+ export { renderVideo, videoArgs } from "./video.js";
19
+ export { previewDeck } from "./preview.js";
20
+ export { tiktokZones } from "./readability.js";
21
+ export { setImageLicense, LICENSES } from "./images.js";
package/dist/index.js CHANGED
@@ -11,3 +11,12 @@ export { publishDeck } from "./publish.js";
11
11
  export { planSlots, dueSlots } from "./schedule.js";
12
12
  export { createServer } from "./mcp.js";
13
13
  export { SKILL } from "./skill.js";
14
+ export { syncResults, recordResult, insights, hookTraits, experimentVerdict } from "./results.js";
15
+ export { hookTest, seriesNext, listSeries, translateDeck, repostDeck } from "./variants.js";
16
+ export { collectIdeas, readIdeas, addIdeas, updateIdea } from "./ideas.js";
17
+ export { brandKit } from "./brandkit.js";
18
+ export { appScreenshots } from "./screenshots.js";
19
+ export { renderVideo, videoArgs } from "./video.js";
20
+ export { previewDeck } from "./preview.js";
21
+ export { tiktokZones } from "./readability.js";
22
+ export { setImageLicense, LICENSES } from "./images.js";
package/dist/lint.d.ts CHANGED
@@ -28,6 +28,9 @@ export interface LintResult {
28
28
  export declare function platformsOf(deck: Deck): Set<"tiktok" | "instagram">;
29
29
  export declare function captionText(deck: Deck): string;
30
30
  export declare function renderContext(ws: Workspace, deck: Deck): RenderContext;
31
- export declare function lintDeck(ws: Workspace, deck: Deck, opts?: {
31
+ export interface LintOptions {
32
32
  platforms?: ("tiktok" | "instagram")[];
33
- }): Promise<LintResult>;
33
+ /** Checks before posting: an image whose license is unknown becomes an error. */
34
+ publishing?: boolean;
35
+ }
36
+ export declare function lintDeck(ws: Workspace, deck: Deck, opts?: LintOptions): Promise<LintResult>;
package/dist/lint.js CHANGED
@@ -3,7 +3,8 @@ import { bannedPhrases, normalizeHook, usedHooks } from "./brand.js";
3
3
  import { markupError, plainText } from "./text.js";
4
4
  import { contrast, getTheme } from "./themes.js";
5
5
  import { followsTemplate, getTemplate, shapeText, TEMPLATES } from "./templates.js";
6
- import { imageMeta, needsAttribution } from "./images.js";
6
+ import { imageMeta, needsAttribution, licenseKnown } from "./images.js";
7
+ import { tiktokIssues } from "./readability.js";
7
8
  import { resolveImage } from "./workspace.js";
8
9
  export const LIMITS = {
9
10
  tiktok: { photos: 35, title: 90, caption: 4000, hashtags: 30 },
@@ -76,8 +77,10 @@ export async function lintDeck(ws, deck, opts = {}) {
76
77
  const all = [];
77
78
  deck.slides.forEach((s, i) => {
78
79
  const texts = [s.title, s.body, ...(s.items ?? []), s.author].filter((t) => !!t);
79
- if (!texts.length)
80
+ if (!texts.length && s.kind !== "screenshot")
80
81
  add("error", "empty-slide", `slide ${i + 1} has no text`, i);
82
+ if (s.kind === "screenshot" && !s.image)
83
+ add("error", "screenshot-empty", `slide ${i + 1} is a screenshot slide without the screenshot (image; app_screenshots finds them)`, i);
81
84
  for (const t of texts) {
82
85
  const err = markupError(t);
83
86
  if (err)
@@ -100,6 +103,9 @@ export async function lintDeck(ws, deck, opts = {}) {
100
103
  if (!p)
101
104
  add("error", "image-missing", `slide ${i + 1}: image "${s.image}" is not in this workspace (import it with image_import)`, i);
102
105
  }
106
+ else if (s.kind === "screenshot") {
107
+ /* checked above */
108
+ }
103
109
  else if (theme.design === "photo" || (s.kind === "cover" && theme.design === "magazine" && deck.full_cover)) {
104
110
  add("warning", "no-image", `slide ${i + 1} has no image; the ${theme.name} theme looks best with a photo on every slide`, i);
105
111
  }
@@ -153,6 +159,14 @@ export async function lintDeck(ws, deck, opts = {}) {
153
159
  if (theme.accent_style === "color" && contrast(colors.accent, colors.bg) < 3)
154
160
  add("warning", "accent-contrast", "the accent colour is hard to see on the background");
155
161
  }
162
+ // Images we may not have the right to post
163
+ deck.slides.forEach((s, i) => {
164
+ if (!s.image)
165
+ return;
166
+ const m = imageMeta(ws, s.image);
167
+ if (m && !licenseKnown(m))
168
+ add(opts.publishing ? "error" : "warning", "license-unknown", `slide ${i + 1}: nobody has said the image ${s.image} may be posted (license unknown); if the user owns it or has the rights, record it with image_license, otherwise pick another`, i);
169
+ });
156
170
  // Images that need credit
157
171
  const credits = deck.slides.map((s) => (s.image ? imageMeta(ws, s.image) : null)).filter(needsAttribution);
158
172
  if (credits.length && !/photo|credit|cc by|📷/i.test(deck.caption))
@@ -165,6 +179,8 @@ export async function lintDeck(ws, deck, opts = {}) {
165
179
  try {
166
180
  const laid = await laySlide(ctx, { deck, slide: deck.slides[i], index: i, tipNumber: nums[i], dry: true });
167
181
  layoutIssues.push(...laid.issues);
182
+ if (platforms.has("tiktok"))
183
+ layoutIssues.push(...tiktokIssues(laid.lines, deck.size, i));
168
184
  }
169
185
  catch (e) {
170
186
  add("error", "layout", `slide ${i + 1}: ${e.message}`, i);