@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.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +297 -2
  3. package/dist/bin.d.ts +2 -0
  4. package/dist/bin.js +9 -0
  5. package/dist/brand.d.ts +57 -0
  6. package/dist/brand.js +263 -0
  7. package/dist/brandkit.d.ts +50 -0
  8. package/dist/brandkit.js +212 -0
  9. package/dist/cli.d.ts +1 -0
  10. package/dist/cli.js +355 -0
  11. package/dist/decks.d.ts +44 -0
  12. package/dist/decks.js +100 -0
  13. package/dist/fonts.d.ts +45 -0
  14. package/dist/fonts.js +243 -0
  15. package/dist/gallery.d.ts +35 -0
  16. package/dist/gallery.js +109 -0
  17. package/dist/ideas.d.ts +50 -0
  18. package/dist/ideas.js +146 -0
  19. package/dist/images.d.ts +62 -0
  20. package/dist/images.js +241 -0
  21. package/dist/index.d.ts +21 -0
  22. package/dist/index.js +22 -0
  23. package/dist/lint.d.ts +36 -0
  24. package/dist/lint.js +197 -0
  25. package/dist/mcp.d.ts +3 -0
  26. package/dist/mcp.js +303 -0
  27. package/dist/preview.d.ts +18 -0
  28. package/dist/preview.js +96 -0
  29. package/dist/publish.d.ts +105 -0
  30. package/dist/publish.js +406 -0
  31. package/dist/readability.d.ts +19 -0
  32. package/dist/readability.js +42 -0
  33. package/dist/render.d.ts +92 -0
  34. package/dist/render.js +647 -0
  35. package/dist/results.d.ts +89 -0
  36. package/dist/results.js +252 -0
  37. package/dist/schedule.d.ts +19 -0
  38. package/dist/schedule.js +114 -0
  39. package/dist/schema.d.ts +1159 -0
  40. package/dist/schema.js +211 -0
  41. package/dist/screenshots.d.ts +18 -0
  42. package/dist/screenshots.js +69 -0
  43. package/dist/shape.d.ts +31 -0
  44. package/dist/shape.js +169 -0
  45. package/dist/skill.d.ts +7 -0
  46. package/dist/skill.js +17 -0
  47. package/dist/templates.d.ts +47 -0
  48. package/dist/templates.js +330 -0
  49. package/dist/text.d.ts +40 -0
  50. package/dist/text.js +231 -0
  51. package/dist/themes.d.ts +43 -0
  52. package/dist/themes.js +202 -0
  53. package/dist/variants.d.ts +48 -0
  54. package/dist/variants.js +175 -0
  55. package/dist/version.d.ts +1 -0
  56. package/dist/version.js +1 -0
  57. package/dist/video.d.ts +22 -0
  58. package/dist/video.js +59 -0
  59. package/dist/viral.d.ts +12 -0
  60. package/dist/viral.js +35 -0
  61. package/dist/workspace.d.ts +85 -0
  62. package/dist/workspace.js +322 -0
  63. package/package.json +65 -4
  64. package/skills/open-slideshow/SKILL.md +65 -0
  65. package/skills/open-slideshow/references/brand.md +64 -0
  66. package/skills/open-slideshow/references/channels.md +63 -0
  67. package/skills/open-slideshow/references/ideas.md +23 -0
  68. package/skills/open-slideshow/references/images.md +61 -0
  69. package/skills/open-slideshow/references/languages.md +51 -0
  70. package/skills/open-slideshow/references/publishing.md +70 -0
  71. package/skills/open-slideshow/references/results.md +47 -0
  72. package/skills/open-slideshow/references/review.md +81 -0
  73. package/skills/open-slideshow/references/screenshots.md +26 -0
  74. package/skills/open-slideshow/references/series.md +20 -0
  75. package/skills/open-slideshow/references/templates.md +96 -0
  76. package/skills/open-slideshow/references/troubleshooting.md +92 -0
  77. package/skills/open-slideshow/references/video.md +18 -0
  78. package/skills/open-slideshow/references/writing.md +76 -0
package/dist/lint.js ADDED
@@ -0,0 +1,197 @@
1
+ import { laySlide, tipNumbers, themeFor } from "./render.js";
2
+ import { bannedPhrases, normalizeHook, usedHooks } from "./brand.js";
3
+ import { markupError, plainText } from "./text.js";
4
+ import { contrast, getTheme } from "./themes.js";
5
+ import { followsTemplate, getTemplate, shapeText, TEMPLATES } from "./templates.js";
6
+ import { imageMeta, needsAttribution, licenseKnown } from "./images.js";
7
+ import { tiktokIssues } from "./readability.js";
8
+ import { resolveImage } from "./workspace.js";
9
+ export const LIMITS = {
10
+ tiktok: { photos: 35, title: 90, caption: 4000, hashtags: 30 },
11
+ instagram: { photos: 20, caption: 2200, hashtags: 30 },
12
+ };
13
+ export function platformsOf(deck) {
14
+ const out = new Set();
15
+ for (const a of deck.accounts) {
16
+ const s = a.toLowerCase();
17
+ if (s.includes("tiktok"))
18
+ out.add("tiktok");
19
+ if (s.includes("instagram") || s.startsWith("ig:"))
20
+ out.add("instagram");
21
+ }
22
+ return out;
23
+ }
24
+ export function captionText(deck) {
25
+ const tags = deck.hashtags.map((h) => `#${h}`).join(" ");
26
+ return [deck.caption.trim(), tags].filter(Boolean).join("\n\n");
27
+ }
28
+ export function renderContext(ws, deck) {
29
+ const brand = ws.settings.brand;
30
+ return {
31
+ theme: themeFor({ theme: deck.theme, colors: deck.colors ?? brand.colors }),
32
+ size: deck.size,
33
+ brand: { name: brand.name ?? ws.settings.app.name, handle: brand.handle, icon: brand.icon ? resolveImage(ws, brand.icon) ?? undefined : undefined },
34
+ resolveImage: (ref) => resolveImage(ws, ref),
35
+ locale: deck.language,
36
+ };
37
+ }
38
+ const findPhrase = (text, phrase) => new RegExp(`(^|[^\\p{L}\\p{N}])${phrase.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}([^\\p{L}\\p{N}]|$)`, "iu").test(text);
39
+ export async function lintDeck(ws, deck, opts = {}) {
40
+ const issues = [];
41
+ const add = (level, code, message, slide) => issues.push({ level, code, message, ...(slide === undefined ? {} : { slide }) });
42
+ const theme = getTheme(deck.theme);
43
+ if (!theme) {
44
+ add("error", "unknown-theme", `unknown theme "${deck.theme}"`);
45
+ return finish(issues);
46
+ }
47
+ const platforms = new Set([...platformsOf(deck), ...(opts.platforms ?? [])]);
48
+ const n = deck.slides.length;
49
+ // Structure
50
+ if (deck.slides[0]?.kind !== "cover")
51
+ add("warning", "no-cover", "the first slide is the hook: make it a cover slide");
52
+ if (deck.slides.filter((s) => s.kind === "cover").length > 1)
53
+ add("warning", "many-covers", "more than one cover slide");
54
+ if (n < 3)
55
+ add("warning", "short", `only ${n} slide${n === 1 ? "" : "s"}: slideshows with 5–8 slides keep people swiping`);
56
+ if (n > 12)
57
+ add("warning", "long", `${n} slides: past 10–12 most people stop swiping`);
58
+ if (platforms.has("instagram") && n > LIMITS.instagram.photos)
59
+ add("error", "ig-too-many", `Instagram takes at most ${LIMITS.instagram.photos} images; this deck has ${n}`);
60
+ if (platforms.has("instagram") && n < 2)
61
+ add("error", "ig-too-few", "an Instagram carousel needs at least 2 images");
62
+ if (platforms.has("tiktok") && n > LIMITS.tiktok.photos)
63
+ add("error", "tiktok-too-many", `TikTok takes at most ${LIMITS.tiktok.photos} photos`);
64
+ if (platforms.has("instagram") && deck.size === "9:16")
65
+ add("warning", "ig-916", "Instagram crops 9:16 carousel images to 4:5 in the feed; use 4:5 for Instagram");
66
+ // Template
67
+ if (deck.template) {
68
+ const t = getTemplate(deck.template);
69
+ if (!t)
70
+ add("error", "unknown-template", `unknown template "${deck.template}"; one of ${TEMPLATES.map((x) => x.id).join(", ")}`);
71
+ else if (!followsTemplate(t, deck.slides.map((s) => s.kind)))
72
+ add("warning", "template-shape", `the slides do not follow the ${t.id} template: ${shapeText(t)}. This deck: ${deck.slides.map((s) => s.kind).join(" → ")}`);
73
+ }
74
+ // Words
75
+ const banned = bannedPhrases(ws.settings);
76
+ const brand = ws.settings.brand;
77
+ const all = [];
78
+ deck.slides.forEach((s, i) => {
79
+ const texts = [s.title, s.body, ...(s.items ?? []), s.author].filter((t) => !!t);
80
+ if (!texts.length && s.kind !== "screenshot")
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);
84
+ for (const t of texts) {
85
+ const err = markupError(t);
86
+ if (err)
87
+ add("error", "markup", `slide ${i + 1}: ${err}`, i);
88
+ }
89
+ if (s.kind === "list" && !s.items?.length)
90
+ add("error", "list-empty", `slide ${i + 1} is a list without items`, i);
91
+ if (s.kind === "quote" && !s.title)
92
+ add("error", "quote-empty", `slide ${i + 1} is a quote without the quote (title)`, i);
93
+ if (s.kind === "cover" && !s.title)
94
+ add("error", "cover-empty", `slide ${i + 1} is a cover without a title (the hook)`, i);
95
+ const words = texts.map(plainText).join(" ").split(/\s+/).filter(Boolean).length;
96
+ if (words > 45)
97
+ add("warning", "wordy", `slide ${i + 1} has ${words} words; people read slides in about 2 seconds, keep it under 35`, i);
98
+ if (s.kind === "cover" && s.title && plainText(s.title).split(/\s+/).length > 14)
99
+ add("warning", "long-hook", `the hook has ${plainText(s.title).split(/\s+/).length} words; the best hooks are under 10`, i);
100
+ all.push(...texts.map(plainText));
101
+ if (s.image) {
102
+ const p = resolveImage(ws, s.image);
103
+ if (!p)
104
+ add("error", "image-missing", `slide ${i + 1}: image "${s.image}" is not in this workspace (import it with image_import)`, i);
105
+ }
106
+ else if (s.kind === "screenshot") {
107
+ /* checked above */
108
+ }
109
+ else if (theme.design === "photo" || (s.kind === "cover" && theme.design === "magazine" && deck.full_cover)) {
110
+ add("warning", "no-image", `slide ${i + 1} has no image; the ${theme.name} theme looks best with a photo on every slide`, i);
111
+ }
112
+ if (s.kind === "app" && !brand.icon)
113
+ add("warning", "no-icon", `slide ${i + 1} shows the app but the brand has no icon (brand_set icon, or set the App Store id)`, i);
114
+ });
115
+ const text = [...all, deck.caption].join("\n");
116
+ for (const p of banned)
117
+ if (findPhrase(text, p))
118
+ add(ws.settings.strict_phrases ? "error" : "warning", "banned-phrase", `"${p}" sounds machine-written; say it plainly`);
119
+ for (const w of brand.words_to_avoid)
120
+ if (findPhrase(text, w.toLowerCase()))
121
+ add("error", "brand-word", `the brand never says "${w}"`);
122
+ for (const c of brand.claims_never) {
123
+ const key = c.toLowerCase().replace(/[^\p{L}\p{N} ]/gu, "").trim();
124
+ if (key.split(" ").length <= 4 && findPhrase(text, key))
125
+ add("error", "brand-claim", `the brand never claims "${c}"`);
126
+ }
127
+ if (/\b(lorem ipsum|todo|tbd|xxx)\b/i.test(text) || /\[[^\]]{1,30}\]/.test(text))
128
+ add("error", "placeholder", "placeholder text left in the deck");
129
+ // Hooks already used
130
+ const cover = deck.slides.find((s) => s.kind === "cover");
131
+ if (cover?.title) {
132
+ const key = normalizeHook(cover.title);
133
+ const dup = usedHooks(ws, 500).find((h) => h.deck !== deck.id && normalizeHook(h.hook) === key);
134
+ if (dup)
135
+ add("warning", "repeat-hook", `this hook was used before${dup.deck ? ` in ${dup.deck}` : ""}: "${dup.hook}"`);
136
+ }
137
+ // Caption and hashtags
138
+ const caption = captionText(deck);
139
+ if (!deck.caption.trim())
140
+ add("warning", "no-caption", "no caption");
141
+ if (platforms.has("instagram") && caption.length > LIMITS.instagram.caption)
142
+ add("error", "ig-caption", `Instagram captions are at most ${LIMITS.instagram.caption} characters; this one is ${caption.length}`);
143
+ if (caption.length > LIMITS.tiktok.caption)
144
+ add("error", "caption-long", `caption is ${caption.length} characters; TikTok takes ${LIMITS.tiktok.caption}`);
145
+ if (deck.hashtags.length > 8)
146
+ add("warning", "many-hashtags", `${deck.hashtags.length} hashtags; 3–5 relevant ones work better`);
147
+ if (new Set(deck.hashtags.map((h) => h.toLowerCase())).size !== deck.hashtags.length)
148
+ add("warning", "dup-hashtags", "the same hashtag twice");
149
+ if (/#[\p{L}\p{N}_]+/u.test(deck.caption) && deck.hashtags.length)
150
+ add("warning", "hashtags-twice", "hashtags are in the caption and in hashtags; they would be posted twice");
151
+ if (deck.tiktok?.cover_index !== undefined && deck.tiktok.cover_index >= n)
152
+ add("error", "cover-index", `tiktok.cover_index ${deck.tiktok.cover_index} is past the last slide`);
153
+ // Colours
154
+ const colors = deck.colors ?? brand.colors;
155
+ if (colors && theme.design !== "photo") {
156
+ const c = contrast(colors.fg, colors.bg);
157
+ if (c < 4.5)
158
+ add(c < 3 ? "error" : "warning", "contrast", `text colour on background has contrast ${c.toFixed(1)}:1; it needs 4.5:1 to read on a phone`);
159
+ if (theme.accent_style === "color" && contrast(colors.accent, colors.bg) < 3)
160
+ add("warning", "accent-contrast", "the accent colour is hard to see on the background");
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
+ });
170
+ // Images that need credit
171
+ const credits = deck.slides.map((s) => (s.image ? imageMeta(ws, s.image) : null)).filter(needsAttribution);
172
+ if (credits.length && !/photo|credit|cc by|📷/i.test(deck.caption))
173
+ add("warning", "attribution", `${credits.length} image(s) are CC BY: credit the authors (credits.txt is written on export; add a credit to the caption)`);
174
+ // Layout: fit every slide exactly as the renderer will.
175
+ const ctx = renderContext(ws, deck);
176
+ const nums = tipNumbers(deck.slides);
177
+ const layoutIssues = [];
178
+ for (let i = 0; i < n; i++) {
179
+ try {
180
+ const laid = await laySlide(ctx, { deck, slide: deck.slides[i], index: i, tipNumber: nums[i], dry: true });
181
+ layoutIssues.push(...laid.issues);
182
+ if (platforms.has("tiktok"))
183
+ layoutIssues.push(...tiktokIssues(laid.lines, deck.size, i));
184
+ }
185
+ catch (e) {
186
+ add("error", "layout", `slide ${i + 1}: ${e.message}`, i);
187
+ }
188
+ }
189
+ for (const li of layoutIssues)
190
+ if (!issues.some((x) => x.code === li.code && x.slide === li.slide))
191
+ add(li.level, li.code, li.message, li.slide);
192
+ return finish(issues);
193
+ }
194
+ function finish(issues) {
195
+ const errors = issues.filter((i) => i.level === "error");
196
+ return { ok: errors.length === 0, errors, warnings: issues.filter((i) => i.level === "warning") };
197
+ }
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function createServer(): McpServer;
3
+ export declare function startMcp(): Promise<void>;
package/dist/mcp.js ADDED
@@ -0,0 +1,303 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import sharp from "sharp";
6
+ import { z } from "zod";
7
+ import { brandContext, ensureIcon, fetchAppStore } from "./brand.js";
8
+ import { newDeck, readManifest, renderDeckById, updateDeck } from "./decks.js";
9
+ import { templateGallery, themeGallery } from "./gallery.js";
10
+ import { TEMPLATES, templateGuide } from "./templates.js";
11
+ import { hitsSheet, importHit, importImageFromFile, importImageFromUrl, listImages, searchImages } from "./images.js";
12
+ import { lintDeck } from "./lint.js";
13
+ import { AppeekyClient, PostizClient, publishDeck } from "./publish.js";
14
+ import { viralLines, viralSearch, viralSheet } from "./viral.js";
15
+ import { assignSlot, dueSlots, planSlots, readPlan, savePlan } from "./schedule.js";
16
+ import { brandSchema, channelSchema, colorsSchema, sizeSchema, slideSchema, textStyleSchema, tiktokOptionsSchema } from "./schema.js";
17
+ import { THEMES } from "./themes.js";
18
+ import { initWorkspace, isInside, listChannels, listDecks, loadChannel, loadDeck, openWorkspace, saveChannel, saveSettings, UserError } from "./workspace.js";
19
+ import { VERSION } from "./version.js";
20
+ import { guideText, guideTopics } from "./skill.js";
21
+ import { insights, recordResult, syncResults, METRICS } from "./results.js";
22
+ import { hookTest, listSeries, repostDeck, seriesNext, translateDeck } from "./variants.js";
23
+ import { addIdeas, collectIdeas, readIdeas, updateIdea } from "./ideas.js";
24
+ import { brandKit } from "./brandkit.js";
25
+ import { appScreenshots } from "./screenshots.js";
26
+ import { renderVideo } from "./video.js";
27
+ import { previewDeck } from "./preview.js";
28
+ import { LICENSES, setImageLicense } from "./images.js";
29
+ import { contactSheet } from "./render.js";
30
+ const text = (t) => ({ type: "text", text: t });
31
+ const json = (v) => text(JSON.stringify(v, null, 2));
32
+ async function imageContent(file, maxWidth = 1500) {
33
+ const buf = await sharp(readFileSync(file)).resize({ width: maxWidth, withoutEnlargement: true }).jpeg({ quality: 78 }).toBuffer();
34
+ return { type: "image", data: buf.toString("base64"), mimeType: "image/jpeg" };
35
+ }
36
+ function wrap(fn) {
37
+ return async (args) => {
38
+ try {
39
+ const ws = openWorkspace(process.env.OPEN_SLIDESHOW_DIR ?? process.cwd());
40
+ const content = await fn(args, ws);
41
+ if (ws.warnings.length)
42
+ content.push(text(`Workspace warnings:\n${ws.warnings.map((w) => `- ${w}`).join("\n")}`));
43
+ return { content };
44
+ }
45
+ catch (e) {
46
+ const msg = e instanceof UserError || e instanceof Error ? e.message : String(e);
47
+ return { content: [text(msg)], isError: true };
48
+ }
49
+ };
50
+ }
51
+ const deckFields = {
52
+ size: sizeSchema.optional().describe("4:5 (feed, default), 1:1 or 9:16 (full-screen TikTok)"),
53
+ theme: z.string().optional().describe("theme id from themes_list"),
54
+ colors: colorsSchema.optional().describe("brand colours instead of the theme's"),
55
+ full_cover: z.boolean().optional(),
56
+ text_style: textStyleSchema.optional(),
57
+ show_handle: z.boolean().optional(),
58
+ caption: z.string().max(4000).optional(),
59
+ hashtags: z.array(z.string()).max(30).optional().describe("without #, 3–5 relevant ones"),
60
+ accounts: z.array(z.string()).optional().describe('e.g. ["tiktok"], ["instagram:@handle"], ["tiktok:all"]'),
61
+ when: z.string().optional().describe("ISO time with zone to schedule, e.g. 2026-12-08T18:30:00+03:00"),
62
+ tiktok: tiktokOptionsSchema.optional(),
63
+ topic: z.string().max(200).optional(),
64
+ template: z.string().optional().describe("template id from templates_list; lint checks the slides follow it"),
65
+ language: z.string().optional(),
66
+ channel: z.string().optional(),
67
+ idea: z.string().optional().describe("the idea id from ideas_list this deck is made from; marks it used"),
68
+ };
69
+ export function createServer() {
70
+ const server = new McpServer({ name: "open-slideshow", version: VERSION }, {
71
+ instructions: "open-slideshow makes TikTok slideshows and Instagram carousels on this machine. You write the words; open-slideshow renders, checks and publishes. " +
72
+ "Always start with brand_context and follow it (tone, claims, hooks already used). If it lists missing brand facts, ask the user and save them with brand_set before writing. " +
73
+ "Detailed guides for every step and error: the guide tool. Let the user pick a theme with themes_preview and a shape with templates_preview. Then deck_create (with template) → deck_render → look at the sheet → fix → deck_publish (preview first; confirm only after the user says yes).",
74
+ });
75
+ server.registerTool("guide", { description: `Detailed open-slideshow guide on one topic: ${guideTopics().join(", ")}. Read the one you need when the task gets there (e.g. review after rendering, troubleshooting on an error).`, inputSchema: { topic: z.string() } }, wrap(async (a) => {
76
+ const t = guideText(a.topic);
77
+ if (!t)
78
+ throw new UserError(`no guide "${a.topic}"; topics: ${guideTopics().join(", ")}`);
79
+ return [text(t)];
80
+ }));
81
+ server.registerTool("workspace_info", { description: "Where open-slideshow works here (standalone folder or Appeeky Spec repo), and what is in it." }, wrap(async (_a, ws) => [
82
+ json({ mode: ws.mode, root: ws.root, dir: ws.dir, initialized: ws.initialized, app: ws.settings.app, default_theme: ws.settings.defaults.theme, decks: listDecks(ws).map((d) => ({ id: d.id, status: d.deck?.status, error: d.error })), channels: listChannels(ws).map((c) => c.id), images: listImages(ws).length }),
83
+ ]));
84
+ server.registerTool("workspace_init", { description: "Set up open-slideshow in this folder (only needed outside a Spec repo).", inputSchema: { app_name: z.string().optional(), app_store_id: z.string().optional(), theme: z.string().optional() } }, wrap(async (a) => {
85
+ const ws = initWorkspace(process.env.OPEN_SLIDESHOW_DIR ?? process.cwd(), { app: { name: a.app_name, app_store_id: a.app_store_id, country: "us" }, ...(a.theme ? { defaults: { theme: a.theme, size: "4:5", language: "en" } } : {}) });
86
+ return [text(`ready in ${ws.dir} (${ws.mode} mode). Next: brand_context.`)];
87
+ }));
88
+ server.registerTool("brand_context", { description: "Everything about the app and brand to write slides in its voice: what it does, audience, tone, claims never to make, the App Store listing, the Spec playbook, hooks already used and how they did, and phrases to avoid. Call it before writing any slide.", inputSchema: { offline: z.boolean().optional() } }, wrap(async (a, ws) => {
89
+ const ctx = await brandContext(ws, { offline: a.offline });
90
+ return [text(ctx.markdown), json({ missing: ctx.missing, questions: ctx.questions, used_hooks: ctx.used_hooks.length })];
91
+ }));
92
+ server.registerTool("brand_set", {
93
+ description: "Save brand facts the user told you (merged into what is there). Lists replace the old list. In a Spec repo the playbook stays the main source; this fills the rest.",
94
+ inputSchema: { brand: brandSchema.partial().describe("name, handle, one_liner, audience, tone[], voice_examples[], words_to_use[], words_to_avoid[], claims_allowed[], claims_never[], cta, colors, icon, notes"), app_store_id: z.string().optional(), default_theme: z.string().optional(), default_size: sizeSchema.optional() },
95
+ }, wrap(async (a, ws) => {
96
+ const s = structuredClone(ws.settings);
97
+ s.brand = brandSchema.parse({ ...s.brand, ...(a.brand ?? {}) });
98
+ if (a.app_store_id) {
99
+ if (ws.mode === "spec")
100
+ throw new UserError("in a Spec repo the App Store id comes from appeeky.spec.yaml");
101
+ s.app.app_store_id = a.app_store_id;
102
+ }
103
+ if (a.default_theme) {
104
+ if (!THEMES.some((t) => t.id === a.default_theme))
105
+ throw new UserError(`unknown theme ${a.default_theme}`);
106
+ s.defaults.theme = a.default_theme;
107
+ }
108
+ if (a.default_size)
109
+ s.defaults.size = a.default_size;
110
+ if (s.brand.icon && !listImages(ws).some((m) => m.ref === s.brand.icon))
111
+ throw new UserError("brand.icon must be an image imported with image_import (its ref)");
112
+ saveSettings(ws, s);
113
+ if (s.app.app_store_id && !s.brand.icon) {
114
+ const ws2 = openWorkspace(ws.root);
115
+ const icon = await ensureIcon(ws2, await fetchAppStore(ws2, s.app.app_store_id, s.app.country));
116
+ if (icon) {
117
+ ws2.settings.brand.icon = icon;
118
+ saveSettings(ws2, ws2.settings);
119
+ }
120
+ }
121
+ return [text(`saved to ${ws.settings_file}`)];
122
+ }));
123
+ server.registerTool("themes_list", { description: "The 10 slide themes: id, look and when to use each." }, wrap(async () => [json(THEMES.map((t) => ({ id: t.id, name: t.name, design: t.design, description: t.description, needs_photos: t.design === "photo" })))]));
124
+ server.registerTool("themes_preview", { description: "One picture with every theme side by side, so the user can pick. With deck, uses that deck's own slides. Show the picture to the user and ask which one; save it with brand_set default_theme or deck_update theme.", inputSchema: { deck: z.string().optional(), slides: z.number().int().min(1).max(3).optional() } }, wrap(async (a, ws) => {
125
+ const g = await themeGallery(ws, a);
126
+ return [text(`Themes, left to right in pairs (labels above each): ${g.themes.map((t) => t.id).join(", ")}\nFile: ${g.sheet}`), await imageContent(g.sheet, 1800)];
127
+ }));
128
+ server.registerTool("templates_list", { description: "Slideshow shapes (tips, mistakes, story, before-after, ranking, quotes, checklist): which slides in which order, what to write on each, and when each works. Pick one with the user before writing; set it as the deck's template." }, wrap(async () => [json(TEMPLATES.map(templateGuide))]));
129
+ server.registerTool("templates_preview", { description: "One picture with every template as a row of example slides, in a theme (default: the user's theme). Show it to the user and ask which shape fits; it also shows how the theme looks across a whole deck.", inputSchema: { theme: z.string().optional(), templates: z.array(z.string()).optional() } }, wrap(async (a, ws) => {
130
+ const g = await templateGallery(ws, a);
131
+ return [text(`Templates in ${g.theme}, one per row: ${g.templates.map((t) => `${t.id} (${t.description})`).join("; ")}\nFile: ${g.sheet}`), await imageContent(g.sheet, 1800)];
132
+ }));
133
+ server.registerTool("deck_create", {
134
+ description: "Write a new slideshow, usually following a template (templates_list). Slides: cover (the hook, title), tip (title + body, numbered automatically), list (title + items), quote (title = the quote, author), bridge (turn to the app), app (shows the app icon and name), text (body only). Wrap words in *stars* for the accent colour. Keep each slide under ~25 words.",
135
+ inputSchema: { id: z.string().optional().describe("folder name; made from the topic when left out"), slides: z.array(slideSchema).min(1).max(35), ...deckFields },
136
+ }, wrap(async (a, ws) => {
137
+ const deck = newDeck(ws, a);
138
+ if (deck.idea && readIdeas(ws).some((i) => i.id === deck.idea))
139
+ updateIdea(ws, deck.idea, { status: "used", deck: deck.id });
140
+ const lint = await lintDeck(ws, deck);
141
+ return [json({ id: deck.id, file: join(ws.dir, "decks", deck.id, "deck.yaml"), errors: lint.errors, warnings: lint.warnings }), text("Next: fix errors with deck_update, then deck_render and look at the sheet.")];
142
+ }));
143
+ server.registerTool("deck_update", {
144
+ description: "Change a deck: any field, the whole slides list, or single slides (slide_edits by 0-based index; a null value removes a field), insert, remove, move.",
145
+ inputSchema: {
146
+ id: z.string(),
147
+ slides: z.array(slideSchema).optional(),
148
+ slide_edits: z.array(z.object({ index: z.number().int().min(0), set: z.record(z.unknown()) })).optional(),
149
+ insert: z.array(z.object({ index: z.number().int().min(0), slide: slideSchema })).optional(),
150
+ remove: z.array(z.number().int().min(0)).optional(),
151
+ move: z.object({ from: z.number().int(), to: z.number().int() }).optional(),
152
+ ...deckFields,
153
+ },
154
+ }, wrap(async (a, ws) => {
155
+ const { id, ...patch } = a;
156
+ const deck = updateDeck(ws, id, patch);
157
+ const lint = await lintDeck(ws, deck);
158
+ return [json({ id: deck.id, slides: deck.slides.length, errors: lint.errors, warnings: lint.warnings })];
159
+ }));
160
+ server.registerTool("deck_get", { description: "A deck's content and status.", inputSchema: { id: z.string() } }, wrap(async (a, ws) => [json({ ...loadDeck(ws, a.id), rendered: readManifest(ws, a.id) })]));
161
+ server.registerTool("deck_list", { description: "All decks with status and hook." }, wrap(async (_a, ws) => [json(listDecks(ws).map((d) => ({ id: d.id, status: d.deck?.status, theme: d.deck?.theme, slides: d.deck?.slides.length, hook: d.deck?.slides[0]?.title, when: d.deck?.when, error: d.error })))]));
162
+ server.registerTool("deck_lint", { description: "Check a deck without rendering: text that does not fit, missing images and glyphs, platform limits, banned phrases, brand rules, repeated hooks.", inputSchema: { id: z.string(), platforms: z.array(z.enum(["tiktok", "instagram"])).optional() } }, wrap(async (a, ws) => [json(await lintDeck(ws, loadDeck(ws, a.id), { platforms: a.platforms }))]));
163
+ server.registerTool("deck_render", { description: "Render the deck to JPEGs and return a sheet of all slides to look at. Always look at it before publishing: check that words are readable over the photos and nothing is cut. safe_zones shows the sheet with TikTok's buttons and caption drawn over the slides.", inputSchema: { id: z.string(), slide: z.number().int().min(1).optional().describe("also return this slide (1-based) full size"), safe_zones: z.boolean().optional() } }, wrap(async (a, ws) => {
164
+ const r = await renderDeckById(ws, a.id);
165
+ const out = [json({ dir: r.dir, files: r.files, errors: r.lint.errors, warnings: r.lint.warnings }), await imageContent(join(r.dir, a.safe_zones ? r.safe_sheet : r.sheet), 1600)];
166
+ if (a.slide && r.files[a.slide - 1])
167
+ out.push(await imageContent(join(r.dir, r.files[a.slide - 1]), 1080));
168
+ return out;
169
+ }));
170
+ server.registerTool("image_search", { description: "Find photos. Openverse needs no key (CC0, public domain, CC BY only); Unsplash or Pexels with the user's own UNSPLASH_ACCESS_KEY / PEXELS_API_KEY. Returns thumbnails to pick from; then image_import with the hit.", inputSchema: { query: z.string().min(2).max(200), provider: z.enum(["openverse", "unsplash", "pexels"]).optional(), orientation: z.enum(["portrait", "landscape", "square"]).optional(), limit: z.number().int().min(1).max(30).optional() } }, wrap(async (a) => {
171
+ const hits = await searchImages(a.query, { ...a, orientation: a.orientation ?? "portrait" });
172
+ if (!hits.length)
173
+ return [text("nothing found; try other words (concrete things work best: 'messy desk at night', not 'productivity')")];
174
+ const sheet = await hitsSheet(hits);
175
+ return [
176
+ json(hits.map((h, i) => ({ n: i + 1, ...h }))),
177
+ ...(sheet ? [text("Numbered thumbnails: pick photos that fit the slide's words and look like a real phone photo."), { type: "image", data: sheet.toString("base64"), mimeType: "image/jpeg" }] : []),
178
+ ];
179
+ }));
180
+ server.registerTool("viral_search", { description: "What already works on TikTok for a topic: the most liked photo slideshows (or videos), with their covers, captions, slide counts and numbers. Use it before writing hooks for a new topic, to learn which angles and shapes people respond to. Needs APPEEKY_API_KEY; each search costs $0.01 from the user's Appeeky balance (the same search within the hour is free), so say so before the first one. Study the patterns, never copy a hook or reuse their images: they belong to their creators.", inputSchema: { query: z.string().min(2).max(120).describe("the topic in the words people search, e.g. 'morning routine', 'study tips'"), kind: z.enum(["slideshow", "video", "any"]).optional(), since: z.enum(["week", "month", "quarter", "half", "any"]).optional(), limit: z.number().int().min(1).max(40).optional() } }, wrap(async (a) => {
181
+ const posts = await viralSearch(a.query, { kind: a.kind ?? "slideshow", since: a.since ?? "quarter", limit: a.limit ?? 20 });
182
+ if (!posts.length)
183
+ return [text("nothing found; try the words people would type into TikTok's search, or a wider since")];
184
+ const sheet = await viralSheet(posts);
185
+ return [
186
+ text(viralLines(posts).join("\n")),
187
+ json(posts.map((p, i) => ({ n: i + 1, ...p, images: p.images.slice(0, 3) }))),
188
+ ...(sheet ? [text("Numbered covers, most liked first. Read the hook on each: its length, its promise, the number in it, who it speaks to. Then write your own for this brand."), { type: "image", data: sheet.toString("base64"), mimeType: "image/jpeg" }] : []),
189
+ ];
190
+ }));
191
+ server.registerTool("image_import", { description: "Bring an image into the workspace: a hit from image_search, an https URL the user gave, or a file path on this machine (e.g. a screenshot, or an image Codex/another tool generated). Returns the ref to use as a slide's image.", inputSchema: { hit: z.record(z.unknown()).optional(), url: z.string().optional(), path: z.string().optional(), license: z.string().optional(), author: z.string().optional() } }, wrap(async (a, ws) => {
192
+ const n = [a.hit, a.url, a.path].filter(Boolean).length;
193
+ if (n !== 1)
194
+ throw new UserError("give exactly one of hit, url or path");
195
+ const meta = a.hit ? await importHit(ws, a.hit) : a.url ? await importImageFromUrl(ws, a.url, { license: a.license ?? "unknown", author: a.author }) : await importImageFromFile(ws, a.path, { license: a.license ?? "own", author: a.author });
196
+ return [json(meta), ...(meta.license === "unknown" ? [text("License unknown: only use it if the user owns it or has the right to post it.")] : [])];
197
+ }));
198
+ server.registerTool("image_list", { description: "Images already in the workspace." }, wrap(async (_a, ws) => [json(listImages(ws))]));
199
+ server.registerTool("channel_save", { description: "Create or change a channel: an account plan with schedule (window or fixed times, days, per_day, timezone, prepare), content rules (audience, topics, never, slide_count, bridge, brand) and design. Starts disabled.", inputSchema: { channel: channelSchema.partial().extend({ id: z.string(), name: z.string().optional() }) } }, wrap(async (a, ws) => {
200
+ let base = { name: a.channel.id };
201
+ try {
202
+ base = loadChannel(ws, a.channel.id);
203
+ }
204
+ catch {
205
+ /* new */
206
+ }
207
+ const ch = saveChannel(ws, { ...base, ...a.channel });
208
+ return [json(ch)];
209
+ }));
210
+ server.registerTool("channel_list", { description: "Channels and their schedules." }, wrap(async (_a, ws) => [json(listChannels(ws))]));
211
+ server.registerTool("plan", { description: "Work out the next post times for enabled channels and save them. Returns the slots; due ones need a deck.", inputSchema: { days: z.number().int().min(1).max(62).optional(), channel: z.string().optional() } }, wrap(async (a, ws) => {
212
+ const chans = listChannels(ws).filter((c) => c.channel && (a.channel ? c.id === a.channel : c.channel.enabled));
213
+ if (!chans.length)
214
+ throw new UserError(a.channel ? `no channel ${a.channel}` : "no enabled channels (channel_save with enabled: true)");
215
+ const fresh = chans.flatMap((c) => planSlots(c.channel, new Date(), a.days ?? 7));
216
+ const all = savePlan(ws, fresh);
217
+ return [json({ slots: all, due: dueSlots(ws) })];
218
+ }));
219
+ server.registerTool("due", { description: "Slots that need a deck now, with the channel's content rules. For each: brand_context, write a deck for the channel, render, look, then deck_publish with when = the slot time." }, wrap(async (_a, ws) => {
220
+ const due = dueSlots(ws);
221
+ return [json(due.map((s) => ({ ...s, channel_rules: loadChannel(ws, s.channel) })))];
222
+ }));
223
+ server.registerTool("slot_assign", { description: "Put a deck in a planned slot (sets the deck's when and channel).", inputSchema: { channel: z.string(), at: z.string(), deck: z.string() } }, wrap(async (a, ws) => {
224
+ const slot = assignSlot(ws, a.channel, a.at, a.deck);
225
+ const ch = loadChannel(ws, a.channel);
226
+ updateDeck(ws, a.deck, { when: slot.at, channel: a.channel, ...(ch.accounts.length ? { accounts: ch.accounts } : {}), ...(ch.tiktok ? { tiktok: ch.tiktok } : {}) });
227
+ return [json(slot)];
228
+ }));
229
+ server.registerTool("accounts_list", { description: "Social accounts connected in Appeeky (needs APPEEKY_API_KEY), or with service: postiz the channels connected in Postiz (needs POSTIZ_API_KEY).", inputSchema: { service: z.enum(["appeeky", "postiz"]).optional() } }, wrap(async (a) => [json(await (a.service === "postiz" ? new PostizClient() : new AppeekyClient()).accounts())]));
230
+ server.registerTool("deck_publish", {
231
+ description: "Publish a rendered deck. provider: export (files to a folder), photos (macOS Photos album, post from the phone), appeeky (post or schedule with the user's APPEEKY_API_KEY), postiz (post or schedule through the user's Postiz, cloud or self-hosted, with POSTIZ_API_KEY), spec-draft (in a Spec repo: a draft file Spec sends after review). Without confirm it only shows what would happen: show that to the user, and call with confirm: true only after they agree.",
232
+ inputSchema: { id: z.string(), provider: z.enum(["export", "photos", "appeeky", "postiz", "spec-draft"]), confirm: z.boolean().optional(), again: z.boolean().optional(), when: z.string().optional(), accounts: z.array(z.string()).optional(), out: z.string().optional() },
233
+ }, wrap(async (a, ws) => {
234
+ if (a.out && !isInside(ws.root, a.out))
235
+ throw new UserError("over MCP, export only inside the workspace; use the CLI for other folders");
236
+ const r = await publishDeck(ws, a.id, a);
237
+ return [json(r)];
238
+ }));
239
+ server.registerTool("plan_show", { description: "The saved plan of slots." }, wrap(async (_a, ws) => [json(readPlan(ws))]));
240
+ // ---------- learning from results ----------
241
+ server.registerTool("results_sync", { description: "Bring in how published decks did (views, likes, comments, shares, saves). Decks sent as Spec drafts: from appeeky/social/posts.jsonl (run `appeeky-spec social pull` first). Decks posted through Appeeky: from Appeeky (APPEEKY_API_KEY). Others: results_record." }, wrap(async (_a, ws) => {
242
+ const client = process.env.APPEEKY_API_KEY ? new AppeekyClient() : undefined;
243
+ return [json(await syncResults(ws, client ? (id) => client.analytics(id) : undefined))];
244
+ }));
245
+ server.registerTool("results_record", { description: "Save numbers the user read off TikTok or Instagram for a deck (posted with photos, export or Postiz). One call per platform; the latest replaces the one before.", inputSchema: { id: z.string(), platform: z.enum(["tiktok", "instagram"]).optional(), ...Object.fromEntries(METRICS.map((m) => [m, z.number().int().min(0).optional()])) } }, wrap(async (a, ws) => {
246
+ const { id, ...m } = a;
247
+ const deck = recordResult(ws, id, m);
248
+ return [json({ id, results: deck.results })];
249
+ }));
250
+ server.registerTool("insights", { description: "What worked across measured decks: best hooks, which templates, themes, slide counts, hook kinds and posting times beat the median, hook test winners, and decks worth posting again. Read it before writing new decks; it is also in brand_context once there are results." }, wrap(async (_a, ws) => {
251
+ const r = insights(ws);
252
+ return [text(r.markdown), json({ measured: r.measured, groups: r.groups, experiments: r.experiments, repost_candidates: r.repost_candidates })];
253
+ }));
254
+ server.registerTool("hook_test", { description: "Test hooks: copies of a deck that differ only in the cover (variant a is the deck, then b, c…). Post them on different days (spread_days schedules them apart) or accounts; insights calls a winner once each has enough views.", inputSchema: { id: z.string(), hooks: z.array(z.string().min(1).max(400)).min(1).max(4), spread_days: z.number().int().min(0).max(14).optional() } }, wrap(async (a, ws) => {
255
+ const decks = hookTest(ws, a.id, a.hooks, { spread_days: a.spread_days });
256
+ return [json(decks.map((d) => ({ id: d.id, variant: d.variant, hook: d.slides.find((s) => s.kind === "cover")?.title, when: d.when }))), text("Render each and look at the covers, then publish them on different days or accounts.")];
257
+ }));
258
+ // ---------- series, translations, reposts ----------
259
+ server.registerTool("series_next", { description: "The next part of a series: a new deck with the same look and accounts, linked to the last one, with a 'Part N' label on its cover (label for another language, e.g. 'Bölüm {part}'). The first deck becomes part 1. Write the new part's slides.", inputSchema: { id: z.string().describe("the last part (or the deck that starts the series)"), slides: z.array(slideSchema).min(1).max(35), topic: z.string().max(200).optional(), of: z.number().int().min(2).max(99).optional(), label: z.string().max(40).optional(), when: z.string().optional() } }, wrap(async (a, ws) => {
260
+ const deck = seriesNext(ws, a.id, a.slides, a);
261
+ const lint = await lintDeck(ws, deck);
262
+ const first = deck.series.part === 2 ? loadDeck(ws, deck.series.id) : undefined;
263
+ return [json({ id: deck.id, series: deck.series, errors: lint.errors, warnings: lint.warnings }), ...(first && first.status === "draft" ? [text(`Part 1 (${first.id}) now has the series label on its cover: render it again, and make its preview or video again if you made them.`)] : [])];
264
+ }));
265
+ server.registerTool("series_list", { description: "Series and their parts, in order, with status and times." }, wrap(async (_a, ws) => [json(listSeries(ws))]));
266
+ server.registerTool("deck_translate", { description: "The same deck in another language: give every slide's translated words in order (kinds and list lengths must match); images and crops stay. A new deck, id <deck>-<language>. In a Spec repo, brand_context lists the store's languages.", inputSchema: { id: z.string(), language: z.string().regex(/^[a-z]{2,3}(-[A-Za-z0-9]{2,8})?$/), slides: z.array(slideSchema.partial()).min(1).max(35), caption: z.string().max(4000).optional(), hashtags: z.array(z.string()).max(30).optional(), accounts: z.array(z.string()).optional(), when: z.string().optional() } }, wrap(async (a, ws) => {
267
+ const deck = translateDeck(ws, a.id, a.language, a);
268
+ const lint = await lintDeck(ws, deck);
269
+ return [json({ id: deck.id, language: deck.language, errors: lint.errors, warnings: lint.warnings }), text("Render it and look: other scripts can need a theme with TikTok Sans or Inter.")];
270
+ }));
271
+ server.registerTool("deck_repost", { description: "Post a deck that did well again, at least 30 days later, with a hook nobody has seen (required) and optionally the middle slides in a new order. insights lists candidates.", inputSchema: { id: z.string(), hook: z.string().min(1).max(400), order: z.array(z.number().int().min(0)).optional().describe("every slide index once, cover first"), min_days: z.number().int().min(7).max(365).optional() } }, wrap(async (a, ws) => {
272
+ const deck = repostDeck(ws, a.id, a.hook, a);
273
+ return [json({ id: deck.id, repost_of: deck.repost_of })];
274
+ }));
275
+ // ---------- screenshots, brand kit ----------
276
+ server.registerTool("app_screenshots", { description: "The app's own screenshots, imported to use in a screenshot slide (kind screenshot, image = the ref): from appeeky/screenshots in a Spec repo, otherwise from the App Store listing. Returns a sheet to pick from.", inputSchema: { limit: z.number().int().min(1).max(10).optional(), locale: z.string().optional() } }, wrap(async (a, ws) => {
277
+ const r = await appScreenshots(ws, a);
278
+ const { readFileSync } = await import("node:fs");
279
+ const sheet = await contactSheet(r.images.map((m) => readFileSync(join(ws.dir, "images", m.ref))), "9:16", Math.min(r.images.length, 5), r.images.map((m, i) => `${i + 1}. ${m.ref}`));
280
+ return [json({ source: r.source, images: r.images.map((m) => ({ ref: m.ref, width: m.width, height: m.height, note: m.note })) }), { type: "image", data: sheet.toString("base64"), mimeType: "image/jpeg" }];
281
+ }));
282
+ server.registerTool("brand_kit", { description: "Brand colours, fonts and logo from the app's website (url, or the App Store seller site), plus colours named in a Spec playbook. Shows a proposal with contrast checked; apply: true saves the colours and imports the logo as the icon. Show the proposal to the user before applying.", inputSchema: { url: z.string().optional(), apply: z.boolean().optional() } }, wrap(async (a, ws) => [json(await brandKit(ws, a))]));
283
+ server.registerTool("image_license", { description: `Record who may post an image: own (the user's), licensed (bought or permission given), cc0, pdm, by-4.0… or unknown. Images with an unknown license cannot be published. Only set what the user tells you.`, inputSchema: { ref: z.string(), license: z.enum(LICENSES), author: z.string().max(200).optional(), note: z.string().max(300).optional() } }, wrap(async (a, ws) => [json(setImageLicense(ws, a.ref, a.license, a))]));
284
+ // ---------- ideas ----------
285
+ server.registerTool("ideas_collect", { description: "Fill the idea queue from what is already known: questions in comments, wishes and praise in reviews, the listing's features, playbook wins, channel topics not used yet. Nothing is sent anywhere.", inputSchema: { offline: z.boolean().optional(), limit: z.number().int().min(1).max(50).optional() } }, wrap(async (a, ws) => {
286
+ const r = await collectIdeas(ws, a);
287
+ return [json(r), text("Pick one with the user, write a deck from it (deck_create with idea: <id>), and stay true to the evidence.")];
288
+ }));
289
+ server.registerTool("ideas_list", { description: "The idea queue, newest first.", inputSchema: { status: z.enum(["new", "used", "skipped"]).optional() } }, wrap(async (a, ws) => [json(readIdeas(ws).filter((i) => !a.status || i.status === a.status).reverse())]));
290
+ server.registerTool("idea_add", { description: "Add an idea the user gave (or one from viral_search patterns) to the queue.", inputSchema: { text: z.string().min(1).max(400), source: z.string().max(40).optional(), evidence: z.string().max(600).optional() } }, wrap(async (a, ws) => [json(addIdeas(ws, [{ text: a.text, source: a.source ?? "user", ...(a.evidence ? { evidence: a.evidence } : {}) }]))]));
291
+ server.registerTool("idea_update", { description: "Mark an idea used (with its deck) or skipped.", inputSchema: { id: z.string(), status: z.enum(["new", "used", "skipped"]), deck: z.string().optional() } }, wrap(async (a, ws) => [json(updateIdea(ws, a.id, a))]));
292
+ // ---------- preview and video ----------
293
+ server.registerTool("deck_preview", { description: "A page that shows the rendered deck on a phone (swipe, caption, TikTok's buttons on a toggle): renders/preview.html. gif adds a small looping preview.gif for a pull request or a chat.", inputSchema: { id: z.string(), gif: z.boolean().optional() } }, wrap(async (a, ws) => {
294
+ const r = await previewDeck(ws, a.id, a);
295
+ return [json(r), text(`Open ${r.html} in a browser.`)];
296
+ }));
297
+ server.registerTool("deck_video", { description: "The rendered deck as a short MP4 (renders/video.mp4) for Reels, Shorts or a TikTok video: each slide for seconds (default 2.5), a soft fade, 9:16, no sound (add music in the app). Needs ffmpeg on the machine.", inputSchema: { id: z.string(), seconds: z.number().min(1).max(10).optional(), fade: z.number().min(0).max(1).optional(), size: sizeSchema.optional() } }, wrap(async (a, ws) => [json(await renderVideo(ws, a.id, a))]));
298
+ return server;
299
+ }
300
+ export async function startMcp() {
301
+ const server = createServer();
302
+ await server.connect(new StdioServerTransport());
303
+ }
@@ -0,0 +1,18 @@
1
+ import { SIZES } from "./schema.js";
2
+ import { type Workspace } from "./workspace.js";
3
+ /** A page that shows the deck the way it looks on a phone: swipe (or arrow keys), caption below, TikTok's buttons on a toggle. */
4
+ export declare function previewHtml(deck: {
5
+ id: string;
6
+ size: keyof typeof SIZES;
7
+ }, files: string[], caption: string, handle?: string): string;
8
+ /**
9
+ * A preview to review before posting: preview.html (open it in a browser) and, with gif, a small
10
+ * looping preview.gif for a pull request or a chat.
11
+ */
12
+ export declare function previewDeck(ws: Workspace, id: string, opts?: {
13
+ gif?: boolean;
14
+ seconds?: number;
15
+ }): Promise<{
16
+ html: string;
17
+ gif?: string;
18
+ }>;