@appeeky/spec 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -139,7 +139,7 @@ A field you leave out of a listing file is not managed by the spec: it is never
139
139
  | `experiment add\|list\|close` | Track growth experiments outside the listing (screenshots, UGC, ads, pricing) with one metric and a check date. |
140
140
  | `screenshots pull\|check` | Download the live App Store screenshots into `appeeky/screenshots/` and check their sizes. |
141
141
  | `report` | Markdown for a pull request: listing changes, check results and coverage against `--base`. |
142
- | `social pull\|check\|push` | Organic social media through the accounts connected in Appeeky: `pull` writes the accounts, recent posts and how they did to `appeeky/social/`; `check` checks the drafts in `appeeky/social/drafts/`; `push` sends them. Needs `APPEEKY_API_KEY`. |
142
+ | `social pull\|check\|push` | Organic social media through the accounts connected in Appeeky: `pull` writes the accounts, recent posts (made through Appeeky and in each platform's app), how they did, comments and followers to `appeeky/social/`; `check` checks the drafts in `appeeky/social/drafts/`; `push` sends them. Needs `APPEEKY_API_KEY`. |
143
143
  | `ugc pull\|generate` | UGC from your Appeeky creator personas: `pull` writes the personas and their clips to `appeeky/ugc/`; `generate` makes a clip from each brief in `appeeky/ugc/briefs/` (`--dry-run` shows the cost in media credits). Needs `APPEEKY_API_KEY`. |
144
144
  | `agents install` | Write the specialist subagents and the `/appeeky-cofounder` review into `.claude/` (`--for opencode` or `all` for `.opencode/`). Files you changed are kept unless `--force`. |
145
145
 
@@ -275,9 +275,12 @@ With the social accounts and creator personas you set up in Appeeky, posts and v
275
275
 
276
276
  ```
277
277
  appeeky/social/accounts.yaml connected accounts (platform, name, id)
278
- appeeky/social/posts.jsonl recent posts and each platform's result: views, likes, comments, shares
279
- appeeky/social/summary.md the last 30 days per platform, and what did best
280
- appeeky/social/drafts/<name>.yaml a post to send: accounts, text, when, media, why
278
+ appeeky/social/posts.jsonl posts made through Appeeky and each platform's result: views, likes, comments, shares
279
+ appeeky/social/native-posts.jsonl posts made in the platform's own app, with the same numbers
280
+ appeeky/social/comments.jsonl recent comments under the accounts' posts
281
+ appeeky/social/insights.yaml followers and growth per account
282
+ appeeky/social/summary.md the last 30 days per platform and account, and what did best across all posts
283
+ appeeky/social/drafts/<name>.yaml a post to send: accounts, text, when, media, tiktok, why
281
284
  appeeky/ugc/personas.yaml creator personas, and whether each can make clips yet
282
285
  appeeky/ugc/clips.jsonl the clips made with them
283
286
  appeeky/ugc/briefs/<name>.yaml a video to make: persona, script, scene, caption, why
@@ -286,14 +289,41 @@ appeeky/ugc/personas/<name>.yaml optional: a persona kept in the repo, with i
286
289
 
287
290
  ```yaml
288
291
  # appeeky/social/drafts/2026-11-10-fan-sounds.yaml
289
- accounts: [twitter, instagram] # platforms from accounts.yaml, or account ids
292
+ accounts: [twitter, tiktok:@sleepysounds]
290
293
  text: "Fan sounds are here. Pick a fan, set a timer, sleep."
291
294
  when: "2026-11-12T16:00:00Z" # without it, the post goes out when it is sent
292
295
  media: ["https://…/fan.mp4"] # Instagram, TikTok and Pinterest need one
296
+ tiktok:
297
+ disclosure: own_brand # it promotes your own app
298
+ inbox_draft: true # lands in the TikTok inbox; finish it in the app
293
299
  why: "Users asked for fan sounds in 9 reviews; it shipped in 3.2."
294
300
  ```
295
301
 
296
- `social check` flags drafts that would fail: a platform with no connected account, text over the platform's limit, a missing image, a time in the past. `ugc generate --dry-run` shows what each brief costs in media credits without making anything. The push workflow written by `init --ci` (and the docker `push` routine) runs `social push --yes` and `ugc generate --yes` when a merged pull request adds drafts or briefs; each is marked `sent` or `generating` and committed, so it never goes out twice. Social media needs the Startup plan or above in Appeeky; a persona needs a look (reference images) before it can make clips.
302
+ Each entry in `accounts` is one of:
303
+
304
+ | Entry | Goes to |
305
+ | --- | --- |
306
+ | `twitter`, `x`, `instagram`, … | the one account connected on that platform; with several, `check` fails and lists their handles |
307
+ | `tiktok:all` | every account connected on that platform |
308
+ | `@sleepysounds`, `u/sleepdev` | the account with that handle (add the platform when two platforms share it) |
309
+ | `tiktok:@sleepysounds` | that handle on that platform |
310
+ | an `id` from accounts.yaml | that account |
311
+
312
+ The `tiktok` block applies to the TikTok accounts the draft goes to. Every key is optional:
313
+
314
+ | Key | Values | Default |
315
+ | --- | --- | --- |
316
+ | `privacy` | `public`, `friends`, `followers`, `only_me` | `public` |
317
+ | `disclosure` | `none`, `own_brand` (promotes your own app or business), `paid_partnership` | `none` |
318
+ | `inbox_draft` | `true` uploads it to the creator's TikTok inbox to finish and post in the app, for example to add TikTok's AI-generated label | `false` |
319
+ | `comments` | `false` turns comments off | `true` |
320
+ | `title` | photo posts: up to 90 characters; the text becomes the description | |
321
+ | `auto_music` | photo posts: `true` lets TikTok add music | |
322
+ | `cover_index` | photo posts: the cover image, from 0 | |
323
+ | `cover_time_ms` | video posts: the frame used as the cover | |
324
+ | `cover_image_url` | video posts: an https image used as the cover | |
325
+
326
+ `social check` flags drafts that would fail: an account that is not connected, a platform name that matches several accounts, text over the platform's limit, a missing image, a time in the past, and TikTok's rules (a disclosed post can't be `only_me` unless it is an inbox draft, at most 35 images, images and a video can't mix, a title over 90 characters). `ugc generate --dry-run` shows what each brief costs in media credits without making anything. The push workflow written by `init --ci` (and the docker `push` routine) runs `social push --yes` and `ugc generate --yes` when a merged pull request adds drafts or briefs; each is marked `sent` or `generating` and committed, so it never goes out twice. Social media needs the Startup plan or above in Appeeky; a persona needs a look (reference images) before it can make clips.
297
327
 
298
328
  ### Clips on your own fal key
299
329
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: appeeky-social
3
- description: Social media specialist for an Appeeky Spec repo. Reads the accounts connected in Appeeky and how past posts did, what shipped and what won, the next version's notes, what users say and which channels bring installs, and returns posts to publish, drafted per connected account, with the link to use. Use it in the co-founder review, or when asked what to post this week.
3
+ description: Social media specialist for an Appeeky Spec repo. Reads the accounts connected in Appeeky, how every post on them did (made through Appeeky or in the platform's app) and what commenters say, what shipped and what won, the next version's notes, what users say and which channels bring installs, and returns posts to publish, drafted per connected account, with the link to use. Use it in the co-founder review, or when asked what to post this week.
4
4
  tools: Read, Grep, Glob, Bash
5
5
  ---
6
6
 
@@ -10,8 +10,12 @@ Run the CLI the way the co-founder tells you (`appeeky-spec <command> --json` or
10
10
 
11
11
  ## Read
12
12
 
13
- - `appeeky/social/accounts.yaml`: the accounts connected in Appeeky. Only draft for these platforms.
14
- - `appeeky/social/summary.md` and `appeeky/social/posts.jsonl`: what was posted, when, and how each did (views, likes, comments, shares); posts still waiting to go out
13
+ - `appeeky/social/accounts.yaml`: the accounts connected in Appeeky. Only draft for these accounts. A platform can have several (one TikTok account per theme, say); each has its own audience.
14
+ - `appeeky/social/summary.md`: the last 30 days per platform and per account, followers, the posts that did best across all of them, posts waiting to go out or sitting in the TikTok inbox
15
+ - `appeeky/social/posts.jsonl`: posts made through Appeeky, and how each did (views, likes, comments, shares)
16
+ - `appeeky/social/native-posts.jsonl`: posts made in the platform's own app, with the same numbers. Most of an account's history is often here, so read it before deciding which hooks work.
17
+ - `appeeky/social/comments.jsonl`: what people write under the posts (`own: true` is the account replying). Questions and objections here are post ideas.
18
+ - `appeeky/social/insights.yaml`: followers and growth per account
15
19
  - `appeeky/social/drafts/`: drafts already waiting, so you do not repeat them
16
20
  - `status --json`, `log --json` and `appeeky/releases/*.yaml`: what went live and what won
17
21
  - `whatsNew` in `appeeky/store/**`, and the app's git history since the last version tag (`git log --oneline`, `git tag`)
@@ -26,11 +30,14 @@ Run the CLI the way the co-founder tells you (`appeeky-spec <command> --json` or
26
30
  - A result worth sharing (a rank won, a rating that rose), said plainly
27
31
  - Something users praise that the posts never mention
28
32
  - The channels that bring installs that pay, so posts go there first
29
- - What kind of post did best on each platform, and what never got seen
33
+ - Which hooks (the first line) did best on each account, across all its posts, and what never got seen
34
+ - What commenters ask again and again
30
35
 
31
36
  ## Rules
32
37
 
33
38
  - Draft each post for its channel: X (under 280 characters), Instagram (a caption and what the image shows), TikTok (the first line on screen and a caption).
39
+ - Name each account by its handle from `accounts.yaml` (`tiktok:@sleepysounds`), and write each post for that account's theme. A bare platform name only works when one account is connected on it; post the same thing on every account of a platform only when it fits all of them (`tiktok:all`).
40
+ - TikTok: when the post promotes the user's own app, it is branded content: say `disclosure: own_brand`. When the video or images are AI-generated (UGC clips, generated images), TikTok wants its AI-generated label, which Appeeky cannot set yet: say `inbox_draft: true`, so the post lands in the creator's TikTok inbox and they add the label in the app before posting.
34
41
  - Only what the app does today, from the repo. No made-up numbers, quotes or dates. Quote users only from the review files, without names.
35
42
  - Suggest a smart link per channel when `attribution:` is set up, so the post is measured.
36
43
  - Instagram, TikTok and Pinterest need an image or video: name one that exists (a public URL), or say a person has to add it.
@@ -47,7 +54,7 @@ Edit files, post anything, or run `push`, `pull`, `experiment add` or any comman
47
54
  Findings
48
55
  - <one line each, max 5: what shipped or won, and which channels bring installs>
49
56
  Posts to publish (a person posts them)
50
- 1. <platform from accounts.yaml>: "<post text>" (<count>/<limit>). When: <ISO time, or "now">. Media: <URL or "a person adds one">. Why now: <the release or result>. Link: <smart link channel or "none">
57
+ 1. <platform:@handle from accounts.yaml>: "<post text>" (<count>/<limit>). When: <ISO time, or "now">. Media: <URL or "a person adds one">. TikTok: <disclosure, inbox_draft, privacy, or "defaults">. Why now: <the release, result or comment>. Link: <smart link channel or "none">
51
58
  2. <channel>: ...
52
59
  Missing data
53
60
  - <what is missing, and the command that fills it>
@@ -27,7 +27,7 @@ Run the review below, write the brief, and propose at most one listing change.
27
27
  - **Not now:** good candidates you did not pick, and why
28
28
 
29
29
  6. **Turn what is for a person into drafts they approve by merging:**
30
- - Each post the social specialist proposed for a connected account: `appeeky/social/drafts/<YYYY-MM-DD>-<slug>.yaml` with `accounts` (platforms from `appeeky/social/accounts.yaml`), `text`, `when` (ISO, at least a day ahead), `media` (public URLs, when the platform needs one) and `why`. Run `social check` and fix every problem, or leave the post out.
30
+ - Each post the social specialist proposed for a connected account: `appeeky/social/drafts/<YYYY-MM-DD>-<slug>.yaml` with `accounts` (each as `<platform>:@handle` from `appeeky/social/accounts.yaml`; a bare platform only when one account is connected on it), `text`, `when` (ISO, at least a day ahead), `media` (public URLs, when the platform needs one), `tiktok` for TikTok posts (`disclosure: own_brand` when it promotes the app, `inbox_draft: true` when the media is AI-generated) and `why`. Run `social check` and fix every problem, or leave the post out.
31
31
  - The video the UGC specialist proposed, if a persona is ready: `appeeky/ugc/briefs/<YYYY-MM-DD>-<slug>.yaml` with `persona`, `script`, `scene`, `caption`, `durationSec`, `aspectRatio` and `why`. Run `ugc generate --dry-run` to show its cost in credits.
32
32
  - After the merge, `social push` sends the posts and `ugc generate` makes the clips. Never run those yourself.
33
33
 
@@ -9,6 +9,12 @@ export interface KeywordMetric {
9
9
  fetchedAt: string;
10
10
  }
11
11
  type Fetcher = typeof fetch;
12
+ /** An error answer from the Appeeky API, with its HTTP status and error code, so callers can tell "not there" from "failed". */
13
+ export declare class AppeekyApiError extends Error {
14
+ readonly status: number;
15
+ readonly code?: string | undefined;
16
+ constructor(message: string, status: number, code?: string | undefined);
17
+ }
12
18
  /**
13
19
  * Small client for the Appeeky API (market data for ASO). Needs an API key
14
20
  * from appeeky.com; every command that uses it also works without it.
@@ -4,6 +4,17 @@ import { dirname, join } from "node:path";
4
4
  import { combineSources, summarizeMeta, summarizeMetrics, summarizeTikTok, } from "./metrics.js";
5
5
  import { normalize } from "./text.js";
6
6
  export const APPEEKY_API_URL = "https://api.appeeky.com/v1";
7
+ /** An error answer from the Appeeky API, with its HTTP status and error code, so callers can tell "not there" from "failed". */
8
+ export class AppeekyApiError extends Error {
9
+ status;
10
+ code;
11
+ constructor(message, status, code) {
12
+ super(message);
13
+ this.status = status;
14
+ this.code = code;
15
+ this.name = "AppeekyApiError";
16
+ }
17
+ }
7
18
  /**
8
19
  * Small client for the Appeeky API (market data for ASO). Needs an API key
9
20
  * from appeeky.com; every command that uses it also works without it.
@@ -25,7 +36,7 @@ export class AppeekyApi {
25
36
  const body = (await res.json().catch(() => null));
26
37
  if (!res.ok) {
27
38
  const retry = res.headers.get("retry-after");
28
- throw new Error(`Appeeky API ${path}: ${body?.error?.message ?? `HTTP ${res.status}`}${retry ? ` (retry after ${retry}s)` : ""}`);
39
+ throw new AppeekyApiError(`Appeeky API ${path}: ${body?.error?.message ?? `HTTP ${res.status}`}${retry ? ` (retry after ${retry}s)` : ""}`, res.status, body?.error?.code);
29
40
  }
30
41
  return body?.data;
31
42
  }
@@ -37,7 +48,7 @@ export class AppeekyApi {
37
48
  });
38
49
  const json = (await res.json().catch(() => null));
39
50
  if (!res.ok)
40
- throw new Error(`Appeeky API ${path}: ${json?.error?.message ?? `HTTP ${res.status}`}`);
51
+ throw new AppeekyApiError(`Appeeky API ${path}: ${json?.error?.message ?? `HTTP ${res.status}`}`, res.status, json?.error?.code);
41
52
  return json?.data;
42
53
  }
43
54
  /** Any other method, e.g. DELETE. */
@@ -49,7 +60,7 @@ export class AppeekyApi {
49
60
  });
50
61
  const json = (await res.json().catch(() => null));
51
62
  if (!res.ok)
52
- throw new Error(`Appeeky API ${path}: ${json?.error?.message ?? `HTTP ${res.status}`}`);
63
+ throw new AppeekyApiError(`Appeeky API ${path}: ${json?.error?.message ?? `HTTP ${res.status}`}`, res.status, json?.error?.code);
53
64
  return json?.data;
54
65
  }
55
66
  /** Keyword opportunities for an app: popular searches it does not rank for yet. */
package/dist/cli.js CHANGED
@@ -3,6 +3,7 @@ import { existsSync } from "node:fs";
3
3
  import { mkdir, readFile, writeFile } from "node:fs/promises";
4
4
  import { join, resolve } from "node:path";
5
5
  import { createInterface } from "node:readline/promises";
6
+ import * as p from "@clack/prompts";
6
7
  import { Command, Option } from "commander";
7
8
  import { adsSnapshot, CHANNEL_LABELS, saveAdsSnapshot } from "./ads.js";
8
9
  import { COFOUNDER_COMMAND, installAgents, parseTargets, TARGET_DIRS } from "./agents.js";
@@ -37,6 +38,7 @@ import { freeStores, writeLoops } from "./loops.js";
37
38
  import { diagnose, findApps, playPackageExists, suggestTargets, targetCandidates, WORKFLOWS } from "./setup.js";
38
39
  import { hasErrors, lintProject } from "./lint.js";
39
40
  import { c, formatChanges, formatCoverage, formatIssues, printJson, storeLabel } from "./output.js";
41
+ import { CODING_AGENTS, onPath, runQuiet, setupPrompt } from "./coding-agents.js";
40
42
  import { configuredStores, planStore, storeHandle } from "./project.js";
41
43
  import { STORES } from "./schema.js";
42
44
  const round = (v) => (v === undefined ? "?" : Math.abs(v) < 1 ? v.toFixed(3) : v.toFixed(2));
@@ -62,6 +64,31 @@ async function ask(question, fallback = "") {
62
64
  rl.close();
63
65
  return answer.trim() || fallback;
64
66
  }
67
+ /** End the setup cleanly on Ctrl+C or Esc. */
68
+ function need(value) {
69
+ if (p.isCancel(value)) {
70
+ p.cancel("Setup stopped. Run it again any time.");
71
+ process.exit(0);
72
+ }
73
+ return value;
74
+ }
75
+ /** A text prompt; Enter gives `defaultValue` when there is one. */
76
+ async function textQ(message, opts = {}) {
77
+ return (need(await p.text({ message, ...opts })) ?? "").trim();
78
+ }
79
+ /** Run something that logs, keeping its lines to show them once it is done. */
80
+ async function captured(task) {
81
+ const lines = [];
82
+ const log = console.log;
83
+ console.log = (...args) => void lines.push(args.map(String).join(" "));
84
+ try {
85
+ await task();
86
+ }
87
+ finally {
88
+ console.log = log;
89
+ }
90
+ return lines;
91
+ }
65
92
  /** A yes/no question that defaults to yes. */
66
93
  async function agree(question) {
67
94
  return !/^n(o)?$/i.test(await ask(`${question} [Y/n]`));
@@ -170,25 +197,31 @@ export function buildProgram() {
170
197
  printJson({ root, created: [SPEC_FILE, `${SPEC_DIR}/`, ...workflows] });
171
198
  });
172
199
  /**
173
- * The guided setup: find the app, write the spec, check that the stores can be reached and
174
- * pull, suggest targets from what it already ranks for, add CI and the agent skills, and
175
- * end on the first coverage table.
200
+ * The guided setup: find the app, make its folder and write the spec, check that the stores
201
+ * can be reached and pull, suggest targets from what it already ranks for, show coverage, then
202
+ * install the skills for the user's coding agent and hand the rest over to it.
176
203
  */
177
- async function wizard(root, locale, country) {
178
- const step = (n, title) => console.log(`\n${c.bold(`${n}/6`)} ${title}`);
179
- console.log(c.bold("Appeeky Spec setup") + c.dim(" Enter keeps the suggestion in brackets."));
180
- step(1, "Your app");
181
- const term = await ask("What is it called on the App Store?");
182
- const found = term ? await findApps(term, country).catch(() => []) : [];
204
+ async function wizard(cwd, locale, country) {
205
+ p.intro(c.badge(" Appeeky Spec "));
206
+ // 1. The app
207
+ const term = await textQ("What is your app called on the App Store?", { validate: (v) => (v?.trim() ? undefined : "Type the app's name") });
208
+ const s = p.spinner();
209
+ s.start("Searching the App Store");
210
+ const found = await findApps(term, country).catch(() => []);
211
+ s.stop(found.length ? `Found ${found.length} ${found.length === 1 ? "app" : "apps"}` : "Not on the App Store in this country");
183
212
  let appStore;
184
- let name = term || "My App";
213
+ let name = term;
185
214
  let storeName = term;
186
215
  let bundleId = "";
187
216
  if (found.length) {
188
- found.forEach((app, i) => console.log(` ${c.cyan(String(i + 1))} ${app.name} ${c.dim(`${app.developer}${app.rating ? ` · ${app.rating}★` : ""} · ${app.id}`)}`));
189
- console.log(` ${c.cyan("0")} ${c.dim("None of these / not on the App Store")}`);
190
- const pick = Number(await ask("Which one?", "1"));
191
- const app = found[pick - 1];
217
+ const pick = need(await p.select({
218
+ message: "Which one is yours?",
219
+ options: [
220
+ ...found.map((app) => ({ value: app.id, label: app.name, hint: `${app.developer}${app.rating ? ` · ${app.rating}★` : ""} · ${app.id}` })),
221
+ { value: "", label: "None of these" },
222
+ ],
223
+ }));
224
+ const app = found.find((a) => a.id === pick);
192
225
  if (app) {
193
226
  appStore = app.id;
194
227
  name = app.name.split(/[:\-–—|]/)[0].trim() || app.name;
@@ -196,23 +229,42 @@ export function buildProgram() {
196
229
  bundleId = app.bundleId;
197
230
  }
198
231
  }
199
- else if (term)
200
- console.log(c.dim(" Not found on the App Store in this country."));
201
232
  if (!appStore) {
202
- const id = await ask("App Store id (digits), or Enter to skip:");
203
- if (/^\d{5,}$/.test(id))
204
- appStore = id;
233
+ const id = await textQ("App Store id (digits)", { placeholder: "Enter to skip", defaultValue: "", validate: (v) => (!v || /^\d{5,}$/.test(v.trim()) ? undefined : "Digits only, like 6763859497") });
234
+ if (id)
235
+ appStore = id.trim();
205
236
  }
206
237
  let googlePlay;
207
- const pkg = await ask("Google Play package, or - for none:", bundleId || "-");
208
- if (pkg && pkg !== "-") {
238
+ if (need(await p.confirm({ message: "Is it on Google Play too?", initialValue: false }))) {
239
+ const pkg = await textQ("Google Play package", { placeholder: bundleId || "com.example.app", defaultValue: bundleId, validate: (v) => (v?.trim() || bundleId ? undefined : "Type the package name") });
240
+ s.start("Checking Google Play");
209
241
  const live = await playPackageExists(pkg);
210
- console.log(live ? ` ${c.green("✓")} found on Google Play` : ` ${c.yellow("!")} no public Google Play page for ${pkg}: kept, check the name`);
242
+ s.stop(live ? `${pkg} is on Google Play` : c.yellow(`No public Google Play page for ${pkg}: kept, check the name`));
211
243
  googlePlay = pkg;
212
244
  }
213
- if (!appStore && !googlePlay)
214
- throw new Error("Give an App Store id or a Google Play package to set up the spec.");
215
- step(2, "The spec");
245
+ if (!appStore && !googlePlay) {
246
+ p.cancel("Give an App Store id or a Google Play package to set up the spec.");
247
+ process.exitCode = 1;
248
+ return;
249
+ }
250
+ // 2. The folder and the spec. Inside an app's repo the spec goes next to the code; anywhere else it gets a folder of its own.
251
+ const inProject = [".git", "package.json", "app.json", "pubspec.yaml"].some((f) => existsSync(join(cwd, f)));
252
+ const suggested = inProject ? "." : `./${slug(name)}`;
253
+ const folder = await textQ("Where should the spec live?", { placeholder: suggested, defaultValue: suggested });
254
+ const root = resolve(cwd, folder);
255
+ const cdHint = folder === "." ? "" : `cd ${folder.replace(/^\.\//, "")}`;
256
+ if (existsSync(join(root, SPEC_FILE))) {
257
+ p.cancel(`${SPEC_FILE} already exists in ${root}. Run \`appeeky-spec doctor\` there to see what is set up.`);
258
+ process.exitCode = 1;
259
+ return;
260
+ }
261
+ // Subcommands parse the global options again, so each one is told the folder.
262
+ const sub = (args) => program.parseAsync(["-C", root, ...args], { from: "user" });
263
+ await mkdir(root, { recursive: true });
264
+ program.setOptionValue("cwd", root);
265
+ const created = [];
266
+ if (!existsSync(join(root, ".git")) && !inProject && (await runQuiet("git", ["init", "-q"], root)).code === 0)
267
+ created.push("a new git repo");
216
268
  await writeSpec(root, {
217
269
  version: 1,
218
270
  app: { name, primaryLocale: locale },
@@ -225,83 +277,117 @@ export function buildProgram() {
225
277
  await mkdir(join(root, SPEC_DIR, "store"), { recursive: true });
226
278
  if (!existsSync(join(root, SPEC_DIR, "playbook.md")))
227
279
  await writeFile(join(root, SPEC_DIR, "playbook.md"), PLAYBOOK);
228
- const ignored = await ignoreLocalData(root);
229
- console.log(` ${c.green("✓")} ${SPEC_FILE}, ${SPEC_DIR}/playbook.md${ignored ? ", .appeeky/ in .gitignore" : ""}`);
230
- step(3, "Store access and your live listing");
280
+ created.push(SPEC_FILE, `${SPEC_DIR}/playbook.md`);
281
+ if (await ignoreLocalData(root))
282
+ created.push(".appeeky/ in .gitignore");
283
+ p.log.success(`${c.bold(folder)} ${c.dim(created.join(", "))}`);
284
+ if (existsSync(join(root, ".git")) && need(await p.confirm({ message: "Add GitHub Actions? (pull request check, push on merge, daily verify)" }))) {
285
+ const written = await writeWorkflows(root);
286
+ p.log.success(`${written.join(", ")}\n${c.dim("The push and the daily run need APPEEKY_API_KEY (or your store keys) as repository secrets.")}`);
287
+ }
288
+ // 3. Store access and the live listing
231
289
  let project = await load();
232
- let reach = diagnose(root, project).filter((x) => x.area === "App Store" || x.area === "Google Play");
233
- printChecks(reach);
290
+ const reachOf = () => diagnose(root, project).filter((x) => x.area === "App Store" || x.area === "Google Play");
291
+ let reach = reachOf();
292
+ logChecks(reach);
234
293
  // A store that cannot be reached: offer to save the user's own key with the store CLI, once per machine.
235
294
  let saved = false;
236
295
  for (const x of reach.filter((r) => r.status === "fail")) {
237
296
  const store = x.area === "App Store" ? "app-store" : "google-play";
238
- if (!(await agree(`Save your own ${x.area} key on this machine now?`)))
297
+ if (!need(await p.confirm({ message: `Save your ${x.area} key on this machine now?`, initialValue: true })))
239
298
  continue;
240
299
  saved = (await saveStoreKey(store, slug(name), store === "app-store" ? appStore : googlePlay)) || saved;
241
300
  }
242
301
  if (saved) {
243
- reach = diagnose(root, project).filter((x) => x.area === "App Store" || x.area === "Google Play");
244
- printChecks(reach);
302
+ reach = reachOf();
303
+ logChecks(reach);
245
304
  }
246
305
  let pulled = false;
247
306
  // Pull each store that can be reached, one at a time: one store's problem does not stop the other.
248
307
  const reachable = reach.filter((x) => x.status === "ok").map((x) => (x.area === "App Store" ? "app-store" : "google-play"));
249
- if (reachable.length && (await agree(`Pull your live listing from ${reachable.map((s) => storeLabel(s)).join(" and ")} now?`))) {
308
+ if (reachable.length && need(await p.confirm({ message: `Pull your live listing from ${reachable.map(storeLabel).join(" and ")} now?` }))) {
250
309
  for (const store of reachable) {
310
+ s.start(`Pulling your ${storeLabel(store)} listing`);
251
311
  try {
252
- await program.parseAsync(["pull", "--store", store], { from: "user" });
312
+ const lines = await captured(() => sub(["pull", "--store", store]));
313
+ s.stop(`Pulled your ${storeLabel(store)} listing`);
314
+ if (lines.length)
315
+ p.log.message(lines.join("\n"));
253
316
  pulled = true;
254
317
  }
255
318
  catch (e) {
256
- console.log(` ${c.red("✗")} ${e.message}`);
319
+ s.error(`${storeLabel(store)}: ${e.message}`);
257
320
  }
258
321
  }
259
322
  }
260
323
  if (reachable.length < reach.length)
261
- console.log(c.dim(" Set up access for the rest as above, then run `appeeky-spec pull`."));
262
- step(4, `The searches to win in ${country.toUpperCase()}`);
324
+ p.log.info(c.dim("Your agent can walk you through store access at the end."));
325
+ // 4. Targets
263
326
  project = await load();
264
327
  // Without a pulled listing, the App Store name still says what the app is for.
265
328
  const candidates = targetCandidates(project, 14, storeName);
266
- const ranked = await suggestTargets(candidates, appStore, country, itunesRankSource());
329
+ s.start(`Checking where ${name} ranks for ${candidates.length} ${candidates.length === 1 ? "search" : "searches"} in ${country.toUpperCase()}`);
330
+ const ranked = await suggestTargets(candidates, appStore, country, itunesRankSource()).catch(() => []);
331
+ s.stop(ranked.length ? `Searches to win in ${country.toUpperCase()}` : "No ranked searches found yet");
267
332
  let targets = [];
268
333
  if (ranked.length) {
269
- for (const r of ranked)
270
- console.log(` ${r.keyword.padEnd(24)} ${r.rank ? c.green(`#${r.rank}`) : c.dim("not in the top 200")}`);
271
- const answer = await ask("Keep these? Enter for yes, or type your own, comma separated:", "yes");
272
- targets = answer === "yes" ? ranked.map((r) => r.keyword) : answer.split(",").map((x) => x.trim().toLowerCase()).filter(Boolean);
273
- }
274
- else {
275
- const answer = await ask("Type 3 to 5 searches people use to find apps like yours, comma separated:");
276
- targets = answer.split(",").map((x) => x.trim().toLowerCase()).filter((x) => x && !/^(y|yes)$/.test(x));
277
- }
334
+ const picked = need(await p.multiselect({
335
+ message: "Which searches should the listing win?",
336
+ options: ranked.map((r) => ({ value: r.keyword, label: r.keyword, hint: r.rank ? `#${r.rank}` : "not in the top 200" })),
337
+ initialValues: ranked.map((r) => r.keyword),
338
+ required: false,
339
+ }));
340
+ targets = picked;
341
+ }
342
+ const extra = await textQ(targets.length ? "Any more? Comma separated" : "Type 3 to 5 searches people use to find apps like yours, comma separated", { placeholder: "Enter to skip", defaultValue: "" });
343
+ targets = [...new Set([...targets, ...extra.split(",").map((x) => x.trim().toLowerCase()).filter(Boolean)])];
278
344
  if (targets.length) {
279
345
  project.spec.targets[country] = targets;
280
346
  await writeSpec(root, project.spec);
281
- console.log(` ${c.green("✓")} ${targets.length} ${targets.length === 1 ? "target" : "targets"} in ${SPEC_FILE}`);
282
- }
283
- step(5, "Automation");
284
- if (existsSync(join(root, ".git")) && (await agree("Add GitHub Actions (pull request check, push on merge, daily verify)?"))) {
285
- for (const f of await writeWorkflows(root))
286
- console.log(` ${c.green("✓")} ${f}`);
287
- console.log(c.dim(" The push and the daily run need APPEEKY_API_KEY (or your store keys) as repository secrets."));
288
- }
289
- if (await agree("Install the agent skills (npx skills add appeeky/appeeky-spec)?")) {
290
- const result = spawnSync("npx", ["-y", "skills", "add", "appeeky/appeeky-spec"], { cwd: root, stdio: "inherit", shell: process.platform === "win32" });
291
- if (result.status !== 0)
292
- console.log(c.yellow(" The skills did not install. Run `npx skills add appeeky/appeeky-spec` later."));
293
- }
294
- if (await agree(`Add the specialist agents and the /${COFOUNDER_COMMAND} review for Claude Code?`)) {
295
- printInstalled(await installAgents(root, ["claude"]));
296
- console.log(c.dim(` In Claude Code, run /${COFOUNDER_COMMAND} for a growth review. Other agents: \`appeeky-spec agents install --for opencode\`.`));
297
- }
298
- step(6, "Where you stand");
299
- if (pulled && targets.length)
300
- await program.parseAsync(["coverage", "--country", country], { from: "user" });
347
+ p.log.success(`${targets.length} ${targets.length === 1 ? "target" : "targets"} in ${SPEC_FILE}`);
348
+ }
349
+ // 5. Where the listing stands
350
+ if (pulled && targets.length) {
351
+ s.start("Measuring keyword coverage");
352
+ const lines = await captured(() => sub(["coverage", "--country", country])).catch((e) => [c.red(e.message)]);
353
+ s.stop("Keyword coverage");
354
+ p.log.message(lines.join("\n"));
355
+ }
356
+ // 6. The coding agent: skills, specialists, then hand over
357
+ const agent = await pickAgent();
358
+ if (!agent) {
359
+ p.note(`${cdHint ? `${cdHint}\n` : ""}npx skills add appeeky/appeeky-spec\nthen ask your agent to finish the setup`, "Later");
360
+ p.outro(`Done. ${c.dim("`appeeky-spec doctor` shows what is set up and what is missing.")}`);
361
+ return;
362
+ }
363
+ s.start(`Installing the Appeeky Spec skills for ${agent.label}`);
364
+ const skills = await runQuiet("npx", ["-y", "skills", "add", "appeeky/appeeky-spec", "--agent", agent.skills, "--skill", "*", "--yes"], root);
365
+ if (skills.code === 0)
366
+ s.stop(`Skills installed for ${agent.label}`);
301
367
  else
302
- console.log(c.dim(" Pull the listing and add targets, then `appeeky-spec coverage` shows which searches it covers."));
303
- console.log(`\n${c.bold("Next")}: change a listing file (or ask your agent), then ${c.cyan("appeeky-spec diff")} and ${c.cyan('appeeky-spec push --note "why"')}.`);
304
- console.log(c.dim("Run `appeeky-spec doctor` any time to see what is set up and what is missing."));
368
+ s.error(`The skills did not install. Run \`npx skills add appeeky/appeeky-spec\` in ${folder} later.`);
369
+ if (agent.subagents) {
370
+ const files = await installAgents(root, [agent.subagents]);
371
+ p.log.success(`Specialists: ${files.map((f) => f.path.split("/").pop().replace(/\.md$/, "")).join(", ")}${agent.subagents === "claude" ? c.dim(`\n/${COFOUNDER_COMMAND} runs a growth review with them.`) : ""}`);
372
+ }
373
+ const prompt = setupPrompt({ name, pulled, hasTargets: targets.length > 0 });
374
+ const installed = onPath(agent.bin);
375
+ if (installed && need(await p.confirm({ message: `Open ${agent.label} here to finish the setup?` }))) {
376
+ p.outro(`Starting ${c.cyan(agent.bin)} in ${folder}`);
377
+ spawnSync(agent.bin, agent.launch(prompt), { cwd: root, stdio: "inherit", shell: process.platform === "win32" });
378
+ return;
379
+ }
380
+ p.note(`${cdHint ? `${cdHint}\n` : ""}${installed ? agent.bin : `install ${agent.label}, then start it`}\n\n${c.dim(prompt)}`, "Finish with your agent");
381
+ p.outro("Done.");
382
+ }
383
+ /** Ask which coding agent the user works with; installed ones come first. */
384
+ async function pickAgent() {
385
+ const list = [...CODING_AGENTS].sort((a, b) => Number(onPath(b.bin)) - Number(onPath(a.bin)));
386
+ const id = need(await p.select({
387
+ message: "Which coding agent do you use?",
388
+ options: [...list.map((a) => ({ value: a.id, label: a.label, hint: onPath(a.bin) ? undefined : "not installed" })), { value: "", label: "None / later" }],
389
+ }));
390
+ return list.find((a) => a.id === id);
305
391
  }
306
392
  /**
307
393
  * Save a store key with the store's own CLI (`appstore accounts add`, `gps accounts add`), run
@@ -309,31 +395,43 @@ export function buildProgram() {
309
395
  */
310
396
  async function saveStoreKey(store, account, appId) {
311
397
  const cli = STORE_CLIS[store];
398
+ const fileExists = (v) => (v?.trim() && existsSync(resolve(v.trim().replace(/^~(?=\/)/, process.env.HOME ?? "~"))) ? undefined : "No file at that path");
399
+ const filePath = (v) => resolve(v.trim().replace(/^~(?=\/)/, process.env.HOME ?? "~"));
312
400
  let args;
313
401
  if (store === "app-store") {
314
- console.log(c.dim(" App Store Connect → Users and Access → Integrations → App Store Connect API. Role App Manager to push."));
315
- const keyId = await ask(" Key ID:");
316
- const issuer = await ask(" Issuer ID (Enter for an individual key):");
317
- const path = await ask(" Path to the AuthKey_….p8 file:");
318
- if (!keyId || !path)
319
- return false;
320
- args = ["accounts", "add", account, "--key-id", keyId, ...(issuer ? ["--issuer-id", issuer] : []), "--private-key-path", path, ...(appId ? ["--default-app", appId] : []), "--default"];
402
+ p.log.info(c.dim("App Store Connect → Users and Access → Integrations → App Store Connect API. Role App Manager to push."));
403
+ const keyId = await textQ("Key ID", { validate: (v) => (/^[A-Z0-9]{10}$/.test(v?.trim() ?? "") ? undefined : "10 letters and digits, like 2X9R4HXF34") });
404
+ const issuer = await textQ("Issuer ID", { placeholder: "Enter for an individual key", defaultValue: "", validate: (v) => (!v || /^[0-9a-f-]{36}$/i.test(v.trim()) ? undefined : "A UUID, like 57246542-96fe-1a63-e053-0824d011072a") });
405
+ const path = await textQ("Path to the AuthKey_….p8 file", { validate: fileExists });
406
+ args = ["accounts", "add", account, "--key-id", keyId.trim(), ...(issuer ? ["--issuer-id", issuer.trim()] : []), "--private-key-path", filePath(path), ...(appId ? ["--default-app", appId] : []), "--default"];
321
407
  }
322
408
  else {
323
- console.log(c.dim(" A Google Cloud service account with the Android Publisher API, invited in Play Console → Users and permissions."));
324
- const path = await ask(" Path to its JSON key:");
325
- if (!path)
326
- return false;
327
- args = ["accounts", "add", account, "--credentials", path, ...(appId ? ["--default-package", appId] : []), "--default"];
328
- }
329
- const result = spawnSync("npx", ["-y", "-p", cli.npmPackage, cli.bin, ...args], { stdio: "inherit", shell: process.platform === "win32" });
330
- if (result.status === 0) {
331
- console.log(` ${c.green("✓")} saved as "${account}" in the ${cli.bin} CLI's config (not in this repo)`);
409
+ p.log.info(c.dim("A Google Cloud service account with the Android Publisher API, invited in Play Console → Users and permissions."));
410
+ const path = await textQ("Path to its JSON key", { validate: fileExists });
411
+ args = ["accounts", "add", account, "--credentials", filePath(path), ...(appId ? ["--default-package", appId] : []), "--default"];
412
+ }
413
+ const s = p.spinner();
414
+ s.start(`Saving the key with the ${cli.bin} CLI`);
415
+ const result = await runQuiet("npx", ["-y", "-p", cli.npmPackage, cli.bin, ...args], process.cwd());
416
+ if (result.code === 0) {
417
+ s.stop(`Saved as "${account}" in the ${cli.bin} CLI's config (not in this repo)`);
332
418
  return true;
333
419
  }
334
- console.log(` ${c.red("✗")} ${cli.bin} accounts add failed: run it again later with the command above.`);
420
+ s.error(`${cli.bin} accounts add failed`);
421
+ p.log.message(c.dim(result.output.trim().split("\n").slice(-4).join("\n")));
335
422
  return false;
336
423
  }
424
+ function logChecks(checks) {
425
+ for (const x of checks) {
426
+ const line = `${c.bold(x.area)} ${x.detail}${x.fix && x.status !== "ok" ? `\n${c.dim(x.fix)}` : ""}`;
427
+ if (x.status === "ok")
428
+ p.log.success(line);
429
+ else if (x.status === "warn")
430
+ p.log.warn(line);
431
+ else
432
+ p.log.error(line);
433
+ }
434
+ }
337
435
  function printChecks(checks) {
338
436
  const mark = { ok: c.green("✓"), warn: c.yellow("!"), fail: c.red("✗") };
339
437
  for (const x of checks) {
@@ -782,7 +880,7 @@ export function buildProgram() {
782
880
  const social = program.command("social").description("Organic social media in the repo: accounts, posts and their results, and posts sent through a pull request (needs APPEEKY_API_KEY)");
783
881
  social
784
882
  .command("pull")
785
- .description("Write the connected accounts, recent posts and their analytics to appeeky/social/, and summary.md")
883
+ .description("Write the connected accounts, recent posts and their analytics, posts made in the platform apps, comments and followers to appeeky/social/, and summary.md")
786
884
  .option("--limit <n>", "How many recent posts", "100")
787
885
  .action(async (opts) => {
788
886
  const project = await load();
@@ -792,16 +890,21 @@ export function buildProgram() {
792
890
  const data = await fetchSocial(a, { limit: Number(opts.limit) || 100 });
793
891
  await saveSocial(project.root, data);
794
892
  if (g().json) {
795
- printJson({ accounts: data.accounts.length, posts: data.posts.length });
893
+ printJson({ accounts: data.accounts.length, posts: data.posts.length, nativePosts: data.nativePosts?.length ?? null, comments: data.comments?.length ?? null, insights: data.insights?.length ?? null, warnings: data.warnings ?? [] });
796
894
  return;
797
895
  }
798
896
  console.log(`${c.bold("Accounts")} ${data.accounts.map((x) => `${x.platform} (${x.name})`).join(", ") || c.dim("none connected")}`);
799
- console.log(`${c.bold("Posts")} ${data.posts.length} · ${data.posts.filter((p) => p.platforms.some((x) => x.publishedAt)).length} published`);
800
- console.log(c.dim("Written to appeeky/social/: accounts.yaml, posts.jsonl, summary.md."));
897
+ console.log(`${c.bold("Posts")} ${data.posts.length} through Appeeky · ${data.posts.filter((p) => p.platforms.some((x) => x.publishedAt)).length} published${data.nativePosts ? ` · ${data.nativePosts.length} made in the apps` : ""}`);
898
+ if (data.comments)
899
+ console.log(`${c.bold("Comments")} ${data.comments.length}`);
900
+ for (const w of data.warnings ?? [])
901
+ console.log(`${c.yellow("warn ")} ${w}`);
902
+ const files = ["accounts.yaml", "posts.jsonl", data.nativePosts && "native-posts.jsonl", data.comments && "comments.jsonl", data.insights && "insights.yaml", "summary.md"].filter(Boolean);
903
+ console.log(c.dim(`Written to appeeky/social/: ${files.join(", ")}.`));
801
904
  });
802
905
  social
803
906
  .command("check")
804
- .description("Check the drafts in appeeky/social/drafts/: connected accounts, length, media, time")
907
+ .description("Check the drafts in appeeky/social/drafts/: which account each goes to, length, media, TikTok options, time")
805
908
  .action(async () => {
806
909
  const project = await load();
807
910
  const accounts = await readAccounts(project.root);