@appeeky/open-slideshow 0.0.0-stage → 0.1.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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +227 -2
  3. package/dist/bin.d.ts +2 -0
  4. package/dist/bin.js +9 -0
  5. package/dist/brand.d.ts +55 -0
  6. package/dist/brand.js +246 -0
  7. package/dist/cli.d.ts +1 -0
  8. package/dist/cli.js +261 -0
  9. package/dist/decks.d.ts +44 -0
  10. package/dist/decks.js +90 -0
  11. package/dist/fonts.d.ts +45 -0
  12. package/dist/fonts.js +243 -0
  13. package/dist/gallery.d.ts +35 -0
  14. package/dist/gallery.js +109 -0
  15. package/dist/images.d.ts +49 -0
  16. package/dist/images.js +223 -0
  17. package/dist/index.d.ts +12 -0
  18. package/dist/index.js +13 -0
  19. package/dist/lint.d.ts +33 -0
  20. package/dist/lint.js +181 -0
  21. package/dist/mcp.d.ts +3 -0
  22. package/dist/mcp.js +233 -0
  23. package/dist/publish.d.ts +100 -0
  24. package/dist/publish.js +401 -0
  25. package/dist/render.d.ts +73 -0
  26. package/dist/render.js +515 -0
  27. package/dist/schedule.d.ts +19 -0
  28. package/dist/schedule.js +114 -0
  29. package/dist/schema.d.ts +1004 -0
  30. package/dist/schema.js +174 -0
  31. package/dist/shape.d.ts +31 -0
  32. package/dist/shape.js +169 -0
  33. package/dist/skill.d.ts +7 -0
  34. package/dist/skill.js +17 -0
  35. package/dist/templates.d.ts +44 -0
  36. package/dist/templates.js +185 -0
  37. package/dist/text.d.ts +40 -0
  38. package/dist/text.js +230 -0
  39. package/dist/themes.d.ts +43 -0
  40. package/dist/themes.js +202 -0
  41. package/dist/version.d.ts +1 -0
  42. package/dist/version.js +1 -0
  43. package/dist/viral.d.ts +12 -0
  44. package/dist/viral.js +35 -0
  45. package/dist/workspace.d.ts +80 -0
  46. package/dist/workspace.js +306 -0
  47. package/package.json +65 -4
  48. package/skills/open-slideshow/SKILL.md +52 -0
  49. package/skills/open-slideshow/references/brand.md +54 -0
  50. package/skills/open-slideshow/references/channels.md +63 -0
  51. package/skills/open-slideshow/references/images.md +53 -0
  52. package/skills/open-slideshow/references/languages.md +41 -0
  53. package/skills/open-slideshow/references/publishing.md +70 -0
  54. package/skills/open-slideshow/references/review.md +74 -0
  55. package/skills/open-slideshow/references/templates.md +59 -0
  56. package/skills/open-slideshow/references/troubleshooting.md +82 -0
  57. package/skills/open-slideshow/references/writing.md +76 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Appeeky
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,228 @@
1
- # Temporary Holding Version
1
+ <p align="center"><img src="assets/cover.png" alt="Pixel-art night over mountains: open-slideshow, slideshows your agent writes. Its features with the TikTok and Instagram logos, where it posts through, and five slides open-slideshow rendered, standing in a row on the meadow." width="100%"></p>
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # open-slideshow
4
+
5
+ Make TikTok photo slideshows and Instagram carousels for your app with the coding agent you already use: Claude Code, Codex or Cursor.
6
+
7
+ Your agent writes the words. open-slideshow renders the slides on your machine, checks them, and gets them to your phone or your accounts. It never calls a model, needs no account, and costs nothing to run.
8
+
9
+ ```sh
10
+ npx @appeeky/open-slideshow agent claude # or codex, cursor
11
+ ```
12
+
13
+ Then ask your agent: *"make a TikTok slideshow about how to fall asleep faster"*.
14
+
15
+ ## What it makes
16
+
17
+ Every picture below was written by an agent and rendered by open-slideshow. The photos are CC0 photos found through open-slideshow's own image search.
18
+
19
+ **Tips** · `tiktok-classic`, the outlined captions people use on TikTok
20
+ ![Tips slideshow in the tiktok-classic theme](assets/examples/morning.jpg)
21
+
22
+ **Mistakes** · `bold-poster`, condensed capitals with one word on an accent block
23
+ ![Mistakes slideshow in the bold-poster theme](assets/examples/night.jpg)
24
+
25
+ **Checklist** · `magazine-cream`, a serif headline over the photo, then the lists
26
+ ![Checklist carousel in the magazine-cream theme](assets/examples/reset.jpg)
27
+
28
+ **Ranking** · `pastel-pop`, no photos needed
29
+ ![Ranking carousel in the pastel-pop theme](assets/examples/study.jpg)
30
+
31
+ **In Japanese** · `soft-shadow`, lines broken between phrases, not inside words
32
+ ![Japanese slideshow in the soft-shadow theme](assets/examples/asa.jpg)
33
+
34
+ ## What your agent gets
35
+
36
+ - **10 themes**, from TikTok-style outlined captions to editorial pages. Your agent shows you all of them in one picture and you pick once.
37
+ - **7 templates**: tips, mistakes, story, before / after, ranking, quotes and checklist. Each one sets which slides go in which order and what to write on each. A preview shows all of them in your theme.
38
+ - **Your brand, before every deck.** The agent reads what your app does, who it is for, the tone, the claims you never make and every hook you already used. It asks you for anything that is missing.
39
+ - **What already works.** With an Appeeky key, your agent finds the most liked TikTok slideshows on your topic, reads their hooks and writes its own on the angles that work ($0.01 a search from your Appeeky balance).
40
+ - **Checks before you post**:
41
+ - text that does not fit, or a glyph a font cannot draw;
42
+ - missing images, or photos without a credit;
43
+ - platform limits;
44
+ - phrases that sound machine-written;
45
+ - hooks you already used.
46
+ - **Your language.** Fonts for Latin, Cyrillic, Greek and Vietnamese ship with open-slideshow. Fonts for Japanese, Chinese, Korean, Arabic, Hebrew, Thai and Hindi download once, the first time a deck needs them.
47
+ - **Photos** from Openverse with no key (CC0, public domain or CC BY), from Unsplash or Pexels with your own key, or from your own files.
48
+ - **A posting calendar**: days, a time window or fixed times, with time zones and clock changes handled.
49
+ - **Posting is up to you.** Export the images, add them to Photos on macOS and post from your phone, or post and schedule through [Appeeky](https://appeeky.com) with your own key.
50
+ - **Detailed skills.** A short flow plus nine guides cover brand, writing, templates, images, languages, review (every lint code), publishing, channels and troubleshooting (every error message). The agent reads a guide only when it needs one.
51
+
52
+ ## Set up your agent
53
+
54
+ <img src="assets/sections/setup.gif" alt="A terminal typing the open-slideshow plugin install, then asking for a TikTok slideshow, over a pixel-art night meadow with the coding agents." width="100%">
55
+
56
+ open-slideshow is two things your agent needs: an **MCP server** (the tools) and a **skill** (how to use them well). Pick one way to install both.
57
+
58
+ ### Claude Code
59
+
60
+ As a plugin, which installs the skill and the MCP server together:
61
+
62
+ ```
63
+ /plugin marketplace add appeeky/open-slideshow
64
+ /plugin install open-slideshow@open-slideshow
65
+ ```
66
+
67
+ Or with the CLI, in your project:
68
+
69
+ ```sh
70
+ npx @appeeky/open-slideshow agent claude
71
+ claude mcp add open-slideshow -- npx -y @appeeky/open-slideshow mcp
72
+ ```
73
+
74
+ This writes `.claude/skills/open-slideshow/` (the skill and its guides).
75
+
76
+ ### Codex
77
+
78
+ ```sh
79
+ npx @appeeky/open-slideshow agent codex
80
+ ```
81
+
82
+ This adds the skill to `AGENTS.md`. Add the MCP server to `~/.codex/config.toml`:
83
+
84
+ ```toml
85
+ [mcp_servers.open-slideshow]
86
+ command = "npx"
87
+ args = ["-y", "@appeeky/open-slideshow", "mcp"]
88
+ ```
89
+
90
+ ### Cursor
91
+
92
+ ```sh
93
+ npx @appeeky/open-slideshow agent cursor
94
+ ```
95
+
96
+ This writes `.cursor/rules/open-slideshow.mdc` and adds the server to `.cursor/mcp.json`.
97
+
98
+ ### Any agent that reads skills
99
+
100
+ The skill is a plain folder, `skills/open-slideshow/`, with `SKILL.md` and `references/`. Install it with the skills CLI:
101
+
102
+ ```sh
103
+ npx skills add appeeky/open-slideshow
104
+ ```
105
+
106
+ Or copy the folder into your agent's skills folder. Then add the MCP server: `npx -y @appeeky/open-slideshow mcp` (stdio).
107
+
108
+ ### Your app
109
+
110
+ In a new folder, tell open-slideshow about your app once:
111
+
112
+ ```sh
113
+ npx @appeeky/open-slideshow init --name "Your App" --app-store-id 123456789
114
+ ```
115
+
116
+ With an App Store id, it reads your listing and imports your icon for the app slide. Your agent asks for the rest (audience, tone, the claims you never make) the first time.
117
+
118
+ ## How a deck gets made
119
+
120
+ 1. **Brand.** The agent reads `brand_context` and asks you what it does not know.
121
+ 2. **Theme.** It shows you all 10 themes in one picture. You pick once.
122
+ 3. **What works.** For a new topic, it looks at the most liked slideshows on TikTok first (with an Appeeky key).
123
+ 4. **Template.** It suggests a shape that fits the topic, and can show you previews.
124
+ 5. **Write.** It writes the deck in your brand's voice.
125
+ 6. **Photos.** It searches for photos, shows you the thumbnails and imports the ones that fit.
126
+ 7. **Render and look.** It renders the deck, looks at every slide, fixes what does not read, and shows you the sheet.
127
+ 8. **Publish, with your yes.** It shows what would happen and waits for you before anything is exported, posted or scheduled.
128
+
129
+ ## A deck
130
+
131
+ ```yaml
132
+ id: fall-asleep-faster
133
+ theme: tiktok-classic
134
+ size: "4:5"
135
+ slides:
136
+ - kind: cover
137
+ title: How I fall asleep in *10 minutes* now
138
+ image: 3f2a9c0d1e4b5a6c.jpg
139
+ - kind: tip
140
+ title: Write tomorrow's list *before* bed
141
+ body: Your brain stops rehearsing it at 2am.
142
+ - kind: list
143
+ title: The last 30 minutes
144
+ items: [Lights low, Phone across the room, Same playlist every night]
145
+ - kind: app
146
+ title: I use *Your App* for it
147
+ body: Free on the App Store.
148
+ caption: Save this for tonight.
149
+ hashtags: [sleep, sleeptips]
150
+ accounts: [tiktok]
151
+ ```
152
+
153
+ Slide kinds: `cover`, `tip`, `list`, `quote`, `bridge`, `app`, `text`. Set `template: tips` (or another) and lint checks the slides follow it. Words in `*stars*` get the accent.
154
+
155
+ ## Posting and scheduling
156
+
157
+ <img src="assets/sections/posting.gif" alt="open-slideshow scheduling a deck through Appeeky, its four slides, and notifications from Appeeky, Postiz and GitHub as posts go out." width="100%">
158
+
159
+ | | Needs | What happens |
160
+ |---|---|---|
161
+ | `export` | nothing | The images, `caption.txt` and `credits.txt` go to a folder |
162
+ | `photos` | macOS | The images go to a Photos album. Post from your phone and add a trending sound there |
163
+ | `appeeky` | `APPEEKY_API_KEY` | Posts now, or at a time, to the TikTok and Instagram accounts you connected in Appeeky. Scheduled posts go out from Appeeky's servers, so your computer can be off |
164
+ | `postiz` | `POSTIZ_API_KEY` (and `POSTIZ_API_URL` when self-hosted) | Posts now, or at a time, to the TikTok and Instagram channels you connected in your Postiz, cloud or self-hosted |
165
+ | `spec-draft` | an Appeeky Spec repo | A draft file that Spec sends after review |
166
+
167
+ A **channel** is a posting plan: accounts, days, a time window, a time zone and content rules. The simplest rhythm is weekly:
168
+
169
+ 1. Ask your agent to "prepare next week's posts".
170
+ 2. Look at the sheets.
171
+ 3. Say yes. Everything is scheduled.
172
+
173
+ ### On GitHub Actions
174
+
175
+ The same week can run without your laptop. Two example workflows are in [`examples/github-actions`](examples/github-actions):
176
+
177
+ - **`open-slideshow-prepare.yml`**, every Monday: your agent plans the week, writes and renders a deck for every slot, fixes the lint errors and opens a pull request. Nothing is posted.
178
+ - **`open-slideshow-schedule.yml`**, when you merge: `open-slideshow publish --scheduled --to appeeky --yes` schedules every rendered deck with a time still ahead. Appeeky posts each one at its time. With Postiz, change it to `--to postiz` and set the `POSTIZ_API_KEY` secret (and `POSTIZ_API_URL` when self-hosted).
179
+
180
+ Merging the pull request is your yes. Add `ANTHROPIC_API_KEY` and `APPEEKY_API_KEY` as repository secrets.
181
+
182
+ ## Inside an Appeeky Spec repo
183
+
184
+ <img src="assets/sections/spec.gif" alt="The files open-slideshow reads and writes in an Appeeky Spec repo, appearing one by one: the spec, the playbook, and a deck with its renders and draft." width="100%">
185
+
186
+ open-slideshow is a standalone tool. If it finds `appeeky.spec.yaml`, it works inside the Spec repo:
187
+
188
+ - It reads the app, `appeeky/playbook.md` (brand), the store listing, connected accounts and past posts from Spec.
189
+ - It writes decks under `appeeky/social/slides/`.
190
+ - It can publish as a Spec draft, which Spec sends after review.
191
+
192
+ It never changes Spec's own files.
193
+
194
+ ## Files
195
+
196
+ ```
197
+ open-slideshow.yaml app, brand and defaults
198
+ decks/<id>/deck.yaml the slides, caption, hashtags, accounts, time
199
+ decks/<id>/renders/ 01.jpg … NN.jpg, sheet.jpg, manifest.json
200
+ channels/<id>.yaml a posting plan: schedule, content rules, design
201
+ images/<hash>.jpg/.json imported images with their license and author
202
+ .open-slideshow/ plan, history, cache
203
+ ```
204
+
205
+ ## CLI
206
+
207
+ ```
208
+ open-slideshow brand what the agent knows about your app
209
+ open-slideshow themes a picture of all themes
210
+ open-slideshow templates a picture of the slideshow shapes
211
+ open-slideshow render <deck> render to JPEGs
212
+ open-slideshow lint <deck> check a deck
213
+ open-slideshow viral <topic> the most liked TikTok slideshows on a topic (Appeeky key)
214
+ open-slideshow publish <deck> --to export|photos|appeeky|postiz|spec-draft --yes
215
+ open-slideshow publish --scheduled --to appeeky|postiz --yes every rendered deck with a time ahead (CI)
216
+ open-slideshow plan / due posting calendar
217
+ open-slideshow mcp the MCP server your agent talks to
218
+ ```
219
+
220
+ ## Privacy
221
+
222
+ - Nothing leaves your machine unless you ask: an image search, a viral search, the App Store lookup for your app, or posting. The one exception: the first deck in Japanese, Chinese, Korean, Arabic, Hebrew, Thai or Hindi downloads that script's font from jsDelivr into `~/.cache/open-slideshow` (set `OPEN_SLIDESHOW_OFFLINE=1` to turn it off).
223
+ - No telemetry.
224
+ - Keys come from your environment (`APPEEKY_API_KEY`, `UNSPLASH_ACCESS_KEY`, `PEXELS_API_KEY`) and are never written to files.
225
+
226
+ ## License
227
+
228
+ MIT. Fonts: TikTok Sans, Inter, Anton, Instrument Serif and Noto Sans (SIL Open Font License). Emoji: Twemoji (CC BY 4.0). Text shaping: HarfBuzz (MIT).
package/dist/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/bin.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import { main } from "./cli.js";
3
+ main().then((code) => {
4
+ if (code >= 0)
5
+ process.exitCode = code;
6
+ }, (e) => {
7
+ process.stderr.write(`${e.stack ?? e}\n`);
8
+ process.exitCode = 1;
9
+ });
@@ -0,0 +1,55 @@
1
+ import { type Brand, type Settings } from "./schema.js";
2
+ import { type Workspace } from "./workspace.js";
3
+ /** Phrases that make a slide sound written by a machine. Warnings by default; `strict_phrases` makes them errors. */
4
+ export declare const BANNED_PHRASES: string[];
5
+ export declare function bannedPhrases(settings: Settings): string[];
6
+ export interface AppStoreInfo {
7
+ id: string;
8
+ name: string;
9
+ seller?: string;
10
+ genre?: string;
11
+ description?: string;
12
+ subtitle?: string;
13
+ rating?: number;
14
+ ratings?: number;
15
+ icon_url?: string;
16
+ url?: string;
17
+ fetched_at: string;
18
+ }
19
+ /** Apple's public lookup: the store name, description and icon, so the agent writes about the real app. */
20
+ export declare function fetchAppStore(ws: Workspace, id: string, country?: string): Promise<AppStoreInfo | null>;
21
+ /** Sets the app icon from the App Store when the brand has none. */
22
+ export declare function ensureIcon(ws: Workspace, info: AppStoreInfo | null): Promise<string | undefined>;
23
+ export interface UsedHook {
24
+ hook: string;
25
+ deck?: string;
26
+ at?: string;
27
+ views?: number;
28
+ likes?: number;
29
+ }
30
+ /** Hooks already used, newest first, with how they did when Spec has the numbers. */
31
+ export declare function usedHooks(ws: Workspace, limit?: number): UsedHook[];
32
+ export declare function normalizeHook(h: string): string;
33
+ export interface BrandContext {
34
+ mode: Workspace["mode"];
35
+ app: Settings["app"] & {
36
+ store?: AppStoreInfo | null;
37
+ };
38
+ brand: Brand;
39
+ playbook?: string;
40
+ listing?: string;
41
+ theme: {
42
+ id: string;
43
+ name: string;
44
+ description: string;
45
+ };
46
+ banned_phrases: string[];
47
+ used_hooks: UsedHook[];
48
+ missing: string[];
49
+ questions: string[];
50
+ markdown: string;
51
+ }
52
+ export declare function brandContext(ws: Workspace, opts?: {
53
+ offline?: boolean;
54
+ hooks?: number;
55
+ }): Promise<BrandContext>;
package/dist/brand.js ADDED
@@ -0,0 +1,246 @@
1
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { brandSchema } from "./schema.js";
4
+ import { listDecks, readJson, readJsonl, historyFile, resolveImage, writeAtomic } from "./workspace.js";
5
+ import { plainText } from "./text.js";
6
+ import { getTheme, THEMES } from "./themes.js";
7
+ import { importImageFromUrl } from "./images.js";
8
+ /** Phrases that make a slide sound written by a machine. Warnings by default; `strict_phrases` makes them errors. */
9
+ export const BANNED_PHRASES = [
10
+ "game-changer",
11
+ "game changer",
12
+ "unlock",
13
+ "unleash",
14
+ "elevate",
15
+ "delve",
16
+ "dive into",
17
+ "deep dive",
18
+ "seamless",
19
+ "seamlessly",
20
+ "revolutionize",
21
+ "revolutionary",
22
+ "supercharge",
23
+ "level up your",
24
+ "in today's fast-paced world",
25
+ "in today's world",
26
+ "look no further",
27
+ "it's not just",
28
+ "here's the thing",
29
+ "let that sink in",
30
+ "the secret sauce",
31
+ "harness the power",
32
+ "transform your life",
33
+ "embark on",
34
+ "journey",
35
+ "tapestry",
36
+ "testament to",
37
+ "boost your productivity",
38
+ ];
39
+ export function bannedPhrases(settings) {
40
+ const remove = new Set(settings.banned_phrases.remove.map((p) => p.toLowerCase()));
41
+ return [...new Set([...BANNED_PHRASES.filter((p) => !remove.has(p)), ...settings.banned_phrases.add.map((p) => p.toLowerCase())])];
42
+ }
43
+ const appStoreCache = (ws) => join(ws.state, "cache", "app-store.json");
44
+ /** Apple's public lookup: the store name, description and icon, so the agent writes about the real app. */
45
+ export async function fetchAppStore(ws, id, country = "us") {
46
+ const cached = readJson(appStoreCache(ws), null);
47
+ if (cached && cached.id === id && Date.now() - Date.parse(cached.fetched_at) < 7 * 86_400_000)
48
+ return cached;
49
+ try {
50
+ const res = await fetch(`https://itunes.apple.com/lookup?id=${encodeURIComponent(id)}&country=${encodeURIComponent(country)}&entity=software`, { signal: AbortSignal.timeout(10_000) });
51
+ if (!res.ok)
52
+ return cached;
53
+ const data = (await res.json());
54
+ const r = data.results?.[0];
55
+ if (!r)
56
+ return null;
57
+ const info = {
58
+ id,
59
+ name: String(r.trackName ?? ""),
60
+ seller: r.sellerName ? String(r.sellerName) : undefined,
61
+ genre: r.primaryGenreName ? String(r.primaryGenreName) : undefined,
62
+ description: r.description ? String(r.description).slice(0, 4000) : undefined,
63
+ rating: typeof r.averageUserRating === "number" ? Math.round(r.averageUserRating * 10) / 10 : undefined,
64
+ ratings: typeof r.userRatingCount === "number" ? r.userRatingCount : undefined,
65
+ icon_url: r.artworkUrl512 ? String(r.artworkUrl512) : undefined,
66
+ url: r.trackViewUrl ? String(r.trackViewUrl).split("?")[0] : undefined,
67
+ fetched_at: new Date().toISOString(),
68
+ };
69
+ writeAtomic(appStoreCache(ws), JSON.stringify(info, null, 2));
70
+ return info;
71
+ }
72
+ catch {
73
+ return cached;
74
+ }
75
+ }
76
+ /** Sets the app icon from the App Store when the brand has none. */
77
+ export async function ensureIcon(ws, info) {
78
+ const current = ws.settings.brand.icon;
79
+ if (current && resolveImage(ws, current))
80
+ return current;
81
+ if (!info?.icon_url)
82
+ return undefined;
83
+ try {
84
+ const img = await importImageFromUrl(ws, info.icon_url, { source: "app-store", license: "own", note: "app icon" });
85
+ return img.ref;
86
+ }
87
+ catch {
88
+ return undefined;
89
+ }
90
+ }
91
+ function readText(file, max) {
92
+ if (!existsSync(file))
93
+ return undefined;
94
+ const t = readFileSync(file, "utf8").trim();
95
+ return t.length > max ? `${t.slice(0, max)}\n…(cut)` : t;
96
+ }
97
+ /** The store listing Spec keeps: the first locale's text files. */
98
+ function specListing(ws) {
99
+ const dir = ws.spec?.store_dir;
100
+ if (!dir || !existsSync(dir))
101
+ return undefined;
102
+ const parts = [];
103
+ const walk = (d, depth) => {
104
+ if (depth > 3 || parts.join("").length > 3000)
105
+ return;
106
+ for (const f of readdirSync(d).sort()) {
107
+ const p = join(d, f);
108
+ const st = statSync(p);
109
+ if (st.isDirectory())
110
+ walk(p, depth + 1);
111
+ else if (/^(name|subtitle|promotional[-_]?text|description)\.(txt|md)$/i.test(f))
112
+ parts.push(`${f.replace(/\.\w+$/, "")}: ${readFileSync(p, "utf8").trim().slice(0, 1500)}`);
113
+ }
114
+ };
115
+ walk(dir, 0);
116
+ return parts.length ? parts.join("\n").slice(0, 3500) : undefined;
117
+ }
118
+ /** Hooks already used, newest first, with how they did when Spec has the numbers. */
119
+ export function usedHooks(ws, limit = 200) {
120
+ const seen = new Set();
121
+ const out = [];
122
+ const add = (h) => {
123
+ const key = normalizeHook(h.hook);
124
+ if (!key || seen.has(key))
125
+ return;
126
+ seen.add(key);
127
+ out.push(h);
128
+ };
129
+ for (const d of listDecks(ws)) {
130
+ const cover = d.deck?.slides.find((s) => s.kind === "cover") ?? d.deck?.slides[0];
131
+ if (cover?.title)
132
+ add({ hook: plainText(cover.title), deck: d.id, at: d.deck?.published.at(-1)?.at });
133
+ }
134
+ for (const e of readJsonl(historyFile(ws)))
135
+ add({ hook: e.hook, deck: e.deck, at: e.at });
136
+ if (ws.spec && existsSync(ws.spec.posts_file)) {
137
+ for (const p of readJsonl(ws.spec.posts_file)) {
138
+ const first = (p.content ?? "").split("\n")[0]?.trim();
139
+ if (!first)
140
+ continue;
141
+ const m = (k) => (p.platforms ?? []).reduce((s, x) => s + (x.metrics?.[k] ?? 0), 0);
142
+ add({ hook: first.slice(0, 160), at: p.platforms?.find((x) => x.publishedAt)?.publishedAt ?? p.createdAt, views: m("views") || m("impressions") || undefined, likes: m("likes") || undefined });
143
+ }
144
+ }
145
+ return out.sort((a, b) => (b.at ?? "").localeCompare(a.at ?? "")).slice(0, limit);
146
+ }
147
+ export function normalizeHook(h) {
148
+ return plainText(h)
149
+ .toLowerCase()
150
+ .replace(/[^\p{L}\p{N}]+/gu, " ")
151
+ .trim();
152
+ }
153
+ const QUESTIONS = {
154
+ name: "What is the app called?",
155
+ one_liner: "In one sentence, what does the app do for someone?",
156
+ audience: "Who is it for? Describe one real person who loves it.",
157
+ tone: "How should the slides sound: e.g. warm, blunt, nerdy, funny, calm?",
158
+ claims_never: "Is there anything the slides must never claim or promise (medical, money, results)?",
159
+ cta: "When a slide mentions the app, what should it ask people to do (e.g. 'free on the App Store')?",
160
+ };
161
+ export async function brandContext(ws, opts = {}) {
162
+ const s = ws.settings;
163
+ const store = s.app.app_store_id && !opts.offline ? await fetchAppStore(ws, s.app.app_store_id, s.app.country) : s.app.app_store_id ? readJson(appStoreCache(ws), null) : null;
164
+ const brand = brandSchema.parse({ ...s.brand, name: s.brand.name ?? s.app.name ?? store?.name });
165
+ const playbook = ws.spec?.playbook ? readText(ws.spec.playbook, 8000) : undefined;
166
+ const listing = ws.mode === "spec" ? specListing(ws) : undefined;
167
+ const theme = getTheme(s.defaults.theme) ?? THEMES[0];
168
+ const missing = [];
169
+ if (!brand.name)
170
+ missing.push("name");
171
+ if (!brand.one_liner && !store?.description && !listing && !playbook)
172
+ missing.push("one_liner");
173
+ if (!brand.audience && !playbook)
174
+ missing.push("audience");
175
+ if (!brand.tone.length && !playbook)
176
+ missing.push("tone");
177
+ if (!brand.claims_never.length && !playbook)
178
+ missing.push("claims_never");
179
+ if (!brand.cta)
180
+ missing.push("cta");
181
+ const hooks = usedHooks(ws, opts.hooks ?? 200);
182
+ const banned = bannedPhrases(s);
183
+ const md = [`# Brand: ${brand.name ?? "(unnamed app)"}`, ""];
184
+ md.push(`Workspace: ${ws.mode === "spec" ? "Appeeky Spec repo (brand comes from appeeky/playbook.md)" : "open-slideshow (brand comes from open-slideshow.yaml)"}`);
185
+ if (brand.one_liner)
186
+ md.push(`What it does: ${brand.one_liner}`);
187
+ if (brand.audience)
188
+ md.push(`For: ${brand.audience}`);
189
+ if (brand.tone.length)
190
+ md.push(`Tone: ${brand.tone.join(", ")}`);
191
+ if (brand.handle)
192
+ md.push(`Handle: ${brand.handle}`);
193
+ if (brand.cta)
194
+ md.push(`Call to action: ${brand.cta}`);
195
+ if (brand.voice_examples.length)
196
+ md.push("", "Sounds like:", ...brand.voice_examples.map((v) => `- "${v}"`));
197
+ if (brand.words_to_use.length)
198
+ md.push(`Words we use: ${brand.words_to_use.join(", ")}`);
199
+ if (brand.words_to_avoid.length)
200
+ md.push(`Words we never use: ${brand.words_to_avoid.join(", ")}`);
201
+ if (brand.claims_allowed.length)
202
+ md.push("", "Claims we can make:", ...brand.claims_allowed.map((c) => `- ${c}`));
203
+ if (brand.claims_never.length)
204
+ md.push("", "Never claim:", ...brand.claims_never.map((c) => `- ${c}`));
205
+ if (brand.notes)
206
+ md.push("", "Notes:", brand.notes);
207
+ if (store) {
208
+ md.push("", `## App Store (${store.name})`);
209
+ if (store.genre)
210
+ md.push(`Category: ${store.genre}`);
211
+ if (store.rating)
212
+ md.push(`Rating: ${store.rating} (${store.ratings ?? 0} ratings)`);
213
+ if (store.url)
214
+ md.push(`Link: ${store.url}`);
215
+ if (store.description)
216
+ md.push("", store.description.slice(0, 1500));
217
+ }
218
+ if (playbook)
219
+ md.push("", "## Playbook (appeeky/playbook.md)", playbook);
220
+ if (listing)
221
+ md.push("", "## Store listing (appeeky/store)", listing);
222
+ md.push("", `## Default theme: ${theme.name} (${theme.id})`, theme.description);
223
+ md.push("", "## Do not write", banned.join(", "));
224
+ if (hooks.length) {
225
+ md.push("", `## Hooks already used (${hooks.length}, newest first): do not repeat them or their angle`);
226
+ for (const h of hooks.slice(0, 60))
227
+ md.push(`- ${h.hook}${h.views ? ` (${h.views} views${h.likes ? `, ${h.likes} likes` : ""})` : ""}`);
228
+ }
229
+ if (missing.length) {
230
+ md.push("", "## Missing: ask the user before writing slides", ...missing.map((m) => `- ${QUESTIONS[m]}`));
231
+ md.push(ws.mode === "spec" ? "Save the answers in appeeky/playbook.md (Spec) or with brand_set." : "Save the answers with brand_set.");
232
+ }
233
+ return {
234
+ mode: ws.mode,
235
+ app: { ...s.app, store },
236
+ brand,
237
+ playbook,
238
+ listing,
239
+ theme: { id: theme.id, name: theme.name, description: theme.description },
240
+ banned_phrases: banned,
241
+ used_hooks: hooks,
242
+ missing,
243
+ questions: missing.map((m) => QUESTIONS[m]),
244
+ markdown: md.join("\n"),
245
+ };
246
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function main(argv?: string[]): Promise<number>;