@appeeky/spec 0.7.0 → 0.9.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
@@ -30,7 +30,7 @@ npx @appeeky/spec verify # day 7 and day 14: did it work?
30
30
 
31
31
  `pnpm dlx`, `yarn dlx` and `bunx` work the same way. Node 20 or later.
32
32
 
33
- `init` with no options asks for the app's name, finds it on the App Store, checks the Google Play package, pulls every store it can reach, suggests five targets from what the app already ranks for, offers the GitHub workflows (`--ci`) and the agent skills, and ends on the first coverage table. With options (`--name`, `--app-store`, `--google-play`, `--pull`) it does the same without questions, for scripts. It also adds `.appeeky/` to `.gitignore`.
33
+ `init` with no options asks for the app's name, finds it on the App Store, checks the Google Play package, pulls every store it can reach, suggests five targets from what the app already ranks for, offers the GitHub workflows (`--ci`) and the agent skills, and ends on the first coverage table. With options (`--name`, `--app-store`, `--google-play`, `--pull`) it does the same without questions, for scripts: it writes the five suggested targets (or the ones in `--targets "a,b,c"`; `--no-targets` leaves them empty) and the Google Play category, and a store it cannot reach does not stop the other. It also adds `.appeeky/` to `.gitignore`.
34
34
 
35
35
  ## What it does
36
36
 
@@ -119,7 +119,8 @@ A field you leave out of a listing file is not managed by the spec: it is never
119
119
 
120
120
  | Command | What it does |
121
121
  | --- | --- |
122
- | `init` | Create `appeeky.spec.yaml` and `appeeky/`. `--pull` fetches the live listings right away. |
122
+ | `init` | Create `appeeky.spec.yaml` and `appeeky/`. `--pull` fetches the live listings right away, `--targets` sets the first targets. |
123
+ | `doctor` | What is set up and what is missing, with the fix for each. It calls the hosted gateways once to check that the key reaches the stores (`--offline` skips that). |
123
124
  | `pull` | Write the live listings into `appeeky/store/` (overwrites local files). |
124
125
  | `check` | Store limits, ASO rules and screenshot sizes. Exits 1 on errors (`--strict`: on warnings too). |
125
126
  | `coverage` | Which target keywords each storefront indexes, plus tips for storefronts that read a second locale (the US also reads Spanish (Mexico)). |
@@ -413,7 +414,7 @@ aiVisibility:
413
414
 
414
415
  - `visibility init` writes the intents Appeeky already tracks into the spec. With none yet, Appeeky writes them from your listing; run `init` again a few minutes later.
415
416
  - `visibility sync` sends the spec's intents and prompts to Appeeky. Ones only in Appeeky are listed, and archived only with `--prune`. `--dry-run` shows the plan.
416
- - `visibility pull` writes `appeeky/visibility/us.yaml`. It shows each intent as `winning`, `weak` or `missing`, the share of answers that name you per assistant, who they name instead, the pages they cite (`yours: true` for your own site), and the fixes Appeeky suggests. What moved since the last pull goes to `appeeky/visibility/changes.md`.
417
+ - `visibility pull` writes `appeeky/visibility/us.yaml`. It shows each intent as `winning`, `weak` or `missing`, the share of answers that name you per assistant, who they name instead, the pages they cite (`yours: true` for your own site, `gap: true` for a site cited for other apps and never for yours), and the fixes Appeeky suggests. `overall` has your share of voice and how often you come first across every answer, `apps` the apps named most, and `searches` what the assistants searched the web for. What moved since the last pull goes to `appeeky/visibility/changes.md`.
417
418
  - `visibility scan` asks the assistants now instead of waiting for the schedule. It uses AI Visibility credits.
418
419
 
419
420
  `verify` reads the daily series as `ai_visibility`, the share of answers that name the app, before and after a push. A description that says what the app is for in the words people use can move it, and so can the pages the assistants cite.
@@ -429,7 +430,7 @@ npx @appeeky/spec visibility scan --local --dry-run
429
430
  npx @appeeky/spec visibility scan --local
430
431
  ```
431
432
 
432
- Each prompt goes to each assistant with web search on, the way the apps answer people, and a second cheap call lists the apps each answer names. The result is the same `appeeky/visibility/<country>.yaml`, plus `history.csv` (one row per scan, intent and assistant, read by `verify`) and `answers/<country>.jsonl` with every answer. Add `aliases:` under `aiVisibility` for other names the assistants use for the app.
433
+ Each prompt goes to each assistant with web search on, the way the apps answer people, and a second cheap call lists the apps each answer names. The result is the same `appeeky/visibility/<country>.yaml`, plus `history.csv` (one row per scan, intent and assistant, read by `verify`) and `answers/<country>.jsonl` with every answer and the searches behind it. Add `aliases:` under `aiVisibility` for other names the assistants use for the app.
433
434
 
434
435
  On a schedule: set `VISIBILITY_EVERY` (days, e.g. `7`) as a repository variable or in the docker `.env`, with the keys as secrets, and the daily routine scans when it is due.
435
436
 
@@ -26,7 +26,7 @@ Run the CLI the way the co-founder tells you (`appeeky-spec <command> --json` or
26
26
  - Spare keyword space, including secondary locales a storefront reads (`crossLocalization` in coverage)
27
27
  - Words repeated across name, subtitle and keyword field, and wasted characters
28
28
  - Competitors that climbed on your targets or changed their listing recently
29
- - Questions where AI assistants name competitors instead of this app, and the words they use
29
+ - Questions where AI assistants name competitors instead of this app, and the words they use: `namedInstead`, the `gap` sites under `sources` and the `searches` in the visibility files
30
30
  - Google queries that bring people to the website and are not targets yet
31
31
  - The category rank trend over the last weeks
32
32
 
@@ -2,6 +2,7 @@ import { existsSync } from "node:fs";
2
2
  import { mkdir, readFile, writeFile } from "node:fs/promises";
3
3
  import { dirname, join } from "node:path";
4
4
  import { combineSources, summarizeMeta, summarizeMetrics, summarizeTikTok, } from "./metrics.js";
5
+ import { explainAppeekyError } from "./transport.js";
5
6
  import { normalize } from "./text.js";
6
7
  export const APPEEKY_API_URL = "https://api.appeeky.com/v1";
7
8
  /** An error answer from the Appeeky API, with its HTTP status and error code, so callers can tell "not there" from "failed". */
@@ -9,7 +10,7 @@ export class AppeekyApiError extends Error {
9
10
  status;
10
11
  code;
11
12
  constructor(message, status, code) {
12
- super(message);
13
+ super(explainAppeekyError(message, status));
13
14
  this.status = status;
14
15
  this.code = code;
15
16
  this.name = "AppeekyApiError";
@@ -49,7 +49,9 @@ export interface CategoryPlan {
49
49
  /** Category name for people, e.g. "Health & Fitness". */
50
50
  name?: string;
51
51
  }
52
- /** Which charts to read: the configured category, or the App Store app's own genre. */
52
+ /** The Google Play category id (e.g. VIDEO_PLAYERS) from the app's public Play page, as the App Store genre comes from Apple's lookup. */
53
+ export declare function playCategory(packageName: string, fetcher?: typeof fetch): Promise<string | undefined>;
54
+ /** Which charts to read: the configured category, or the app's own category on each store. */
53
55
  export declare function categoryPlans(project: Project, fetcher?: typeof fetch): Promise<{
54
56
  plans: CategoryPlan[];
55
57
  notes: string[];
package/dist/category.js CHANGED
@@ -80,7 +80,15 @@ export async function appleAppInfo(appId, country, fetcher = fetch) {
80
80
  return null;
81
81
  return { genreId: String(app.primaryGenreId), genre: app.primaryGenreName ?? String(app.primaryGenreId), paid: (app.price ?? 0) > 0 };
82
82
  }
83
- /** Which charts to read: the configured category, or the App Store app's own genre. */
83
+ /** The Google Play category id (e.g. VIDEO_PLAYERS) from the app's public Play page, as the App Store genre comes from Apple's lookup. */
84
+ export async function playCategory(packageName, fetcher = fetch) {
85
+ const res = await fetcher(`https://play.google.com/store/apps/details?id=${encodeURIComponent(packageName)}&hl=en`, { headers: { "User-Agent": "Mozilla/5.0 appeeky-spec" } });
86
+ if (!res.ok)
87
+ return undefined;
88
+ const html = await res.text();
89
+ return /"applicationCategory"\s*:\s*"([A-Z_]+)"/.exec(html)?.[1];
90
+ }
91
+ /** Which charts to read: the configured category, or the app's own category on each store. */
84
92
  export async function categoryPlans(project, fetcher = fetch) {
85
93
  const cfg = project.spec.category ?? {};
86
94
  const ids = rankAppIds(project);
@@ -103,10 +111,14 @@ export async function categoryPlans(project, fetcher = fetch) {
103
111
  notes.push("App Store: category charts need the numeric appId in stores.appStore.");
104
112
  }
105
113
  if (ids["google-play"]) {
106
- if (cfg.googlePlay)
107
- plans.push({ store: "google-play", appId: ids["google-play"], category: cfg.googlePlay, chart: cfg.chart ?? "top-free", countries, name: cfg.googlePlay.toLowerCase().replace(/_/g, " ") });
114
+ const detected = cfg.googlePlay ? undefined : await playCategory(ids["google-play"], fetcher).catch(() => undefined);
115
+ const category = cfg.googlePlay ?? detected;
116
+ if (category)
117
+ plans.push({ store: "google-play", appId: ids["google-play"], category, chart: cfg.chart ?? "top-free", countries, name: category.toLowerCase().replace(/_/g, " ") });
108
118
  else
109
- notes.push("Google Play: set category.googlePlay in appeeky.spec.yaml (e.g. HEALTH_AND_FITNESS) to record its chart.");
119
+ notes.push("Google Play: could not read the app's category. Set category.googlePlay in appeeky.spec.yaml (e.g. HEALTH_AND_FITNESS) to record its chart.");
120
+ if (detected)
121
+ notes.push(`Google Play: category ${detected}, read from the Play page. Set category.googlePlay: ${detected} in appeeky.spec.yaml to pin it.`);
110
122
  }
111
123
  return { plans, notes };
112
124
  }
package/dist/cli.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  import { Command } from "commander";
2
+ /** This package's version, from package.json next to src/ and dist/ (never typed by hand). */
3
+ export declare const VERSION: string;
2
4
  export declare function buildProgram(): Command;
3
5
  export declare function run(argv?: string[]): Promise<void>;
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { spawnSync } from "node:child_process";
2
- import { existsSync } from "node:fs";
2
+ import { existsSync, readFileSync } from "node:fs";
3
3
  import { mkdir, readFile, writeFile } from "node:fs/promises";
4
4
  import { dirname, join, resolve } from "node:path";
5
5
  import { createInterface } from "node:readline/promises";
@@ -13,8 +13,8 @@ import { pullCompetitors, similarApps } from "./competitors.js";
13
13
  import { commentPlatform, deleteComment, draftIssues, fetchSocial, hideComment, likeComment, listComments, readAccounts, readDrafts, replyToComment, resolveAccounts, saveSocial, sendDraft } from "./social.js";
14
14
  import { fetchUgc, findPersona, generateBrief, quoteBrief, readBriefs, readPersonas, saveUgc } from "./ugc.js";
15
15
  import { generateLocal, loadCore, planLocalClip, readAppeekyPersona, readLocalPersona } from "./ugc-local.js";
16
- import { categoryFile, categoryMetricSource, categoryPlans, chartSources, previousRank, readCategoryHistory, readCategoryRanks, saveCategoryRanks } from "./category.js";
17
- import { applySync, bootstrapIntents, languageFor, planSync, pullVisibility, readRemoteIntents, scanVisibility, visibilityMetricSource, visibilityTarget } from "./visibility.js";
16
+ import { categoryFile, categoryMetricSource, categoryPlans, playCategory, chartSources, previousRank, readCategoryHistory, readCategoryRanks, saveCategoryRanks } from "./category.js";
17
+ import { applySync, bootstrapIntents, languageFor, overallLine, planSync, pullVisibility, readRemoteIntents, scanVisibility, visibilityMetricSource, visibilityTarget } from "./visibility.js";
18
18
  import { appContext, daysSinceLocalScan, KEY_NAMES, loadVisibilityCore, localVisibilityMetricSource, planLocalScan, scanLocal } from "./visibility-local.js";
19
19
  import { pullSearchAds, SearchAdsClient, searchAdsMetricSource, searchAdsSource } from "./search-ads.js";
20
20
  import { daysSinceRanks, pullDomain, pullKeywords, pullRanks, quoteSeo, readDataForSeo, webKeywords, webRankMetricSource } from "./dataforseo.js";
@@ -36,7 +36,7 @@ import { invertChanges } from "./diff.js";
36
36
  import { loadProject, recordPull, SPEC_DIR, SPEC_FILE, writeListing, writeSpec } from "./files.js";
37
37
  import { readReleases, releaseId, releaseMarkdown, writeRelease } from "./history.js";
38
38
  import { freeStores, writeLoops } from "./loops.js";
39
- import { diagnose, findApps, playPackageExists, suggestTargets, targetCandidates, WORKFLOWS } from "./setup.js";
39
+ import { diagnose, findApps, probeConnections, playPackageExists, suggestTargets, targetCandidates, WORKFLOWS } from "./setup.js";
40
40
  import { hasErrors, lintProject } from "./lint.js";
41
41
  import { c, formatChanges, formatCoverage, formatIssues, printJson, storeLabel } from "./output.js";
42
42
  import { CODING_AGENTS, onPath, runQuiet, setupPrompt } from "./coding-agents.js";
@@ -48,7 +48,7 @@ function experimentPlaybookLine(e) {
48
48
  const value = e.result?.value !== undefined ? ` (${e.metric} ${round(e.baseline)} → ${round(e.result.value)})` : "";
49
49
  return `- ${e.startedAt.slice(0, 10)}, ${e.type}${e.persona ? `, ${e.persona}` : ""}: ${e.hypothesis} → ${e.status}${value}${e.result?.note ? `. ${e.result.note}` : ""}`;
50
50
  }
51
- import { STORE_CLIS } from "./transport.js";
51
+ import { npxPackage, STORE_CLIS } from "./transport.js";
52
52
  const PLAYBOOK = `# Playbook
53
53
 
54
54
  What worked and what did not for this app. Appeeky Spec and your agent read this
@@ -127,11 +127,22 @@ async function confirm(question) {
127
127
  function storeOption() {
128
128
  return new Option("-s, --store <store>", "Only this store").choices([...STORES]);
129
129
  }
130
+ /** This package's version, from package.json next to src/ and dist/ (never typed by hand). */
131
+ export const VERSION = (() => {
132
+ try {
133
+ return JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
134
+ }
135
+ catch {
136
+ return "unknown";
137
+ }
138
+ })();
139
+ /** Errors the CLI throws on purpose carry a message meant for the user; anything else is a bug worth reporting. */
140
+ const EXPECTED_ERRORS = new Set(["Error", "SpecError", "TransportError", "AppeekyApiError", "CommanderError"]);
130
141
  export function buildProgram() {
131
142
  const program = new Command()
132
143
  .name("appeeky-spec")
133
144
  .description("Your app's store listing as a spec: check it, measure keyword coverage, diff it with the live store and push it.")
134
- .version("0.1.0")
145
+ .version(VERSION)
135
146
  .option("-C, --cwd <dir>", "Run as if started in this folder", process.cwd())
136
147
  .option("--json", "Machine-readable output", false)
137
148
  .addOption(new Option("--via <mode>", "How to reach the stores (overrides the spec)").choices(["auto", "local", "hosted"]));
@@ -139,6 +150,34 @@ export function buildProgram() {
139
150
  const transportOverrides = () => (g().via ? { via: g().via } : {});
140
151
  const load = () => loadProject(g().cwd);
141
152
  const api = () => (process.env.APPEEKY_API_KEY ? new AppeekyApi(process.env.APPEEKY_API_KEY, { baseUrl: process.env.APPEEKY_API_URL }) : undefined);
153
+ /** Pull each store on its own: one that cannot be reached does not stop the other. */
154
+ const pullListings = async (project, only, locales) => {
155
+ const written = [];
156
+ const errors = [];
157
+ const stores = configuredStores(project, only);
158
+ for (const store of stores) {
159
+ try {
160
+ const handle = storeHandle(project, store, transportOverrides());
161
+ if (!g().json)
162
+ console.log(c.dim(`${storeLabel(store)}: pulling via ${handle.transport.label}…`));
163
+ const state = await handle.adapter.pull();
164
+ for (const [locale, listing] of Object.entries(state.listings)) {
165
+ if (locales && !locales.includes(locale))
166
+ continue;
167
+ written.push({ store, locale, file: await writeListing(project.root, store, locale, listing) });
168
+ }
169
+ await recordPull(project.root, store, state.target);
170
+ if (!g().json)
171
+ console.log(`${storeLabel(store)}: ${Object.keys(state.listings).length} locales from ${state.target}`);
172
+ }
173
+ catch (e) {
174
+ errors.push({ store, message: e.message });
175
+ if (!g().json)
176
+ console.error(c.red(`${storeLabel(store)}: ${e.message}`));
177
+ }
178
+ }
179
+ return { written, errors, stores };
180
+ };
142
181
  /** Appeeky API ranks when a key is set (both stores), Apple's public search otherwise (App Store only). */
143
182
  const rankSource = () => {
144
183
  const a = api();
@@ -153,6 +192,8 @@ export function buildProgram() {
153
192
  .option("--locale <locale>", "Primary locale", "en-US")
154
193
  .option("--country <cc>", "First storefront to add targets for", "us")
155
194
  .option("--pull", "Pull the live listings right away", false)
195
+ .option("--targets <searches>", "Comma-separated searches to win in --country (default: five suggested from the app's name and where it already ranks)")
196
+ .option("--no-targets", "Leave targets empty")
156
197
  .option("--ci", "Write the GitHub workflows (pull request check, push on merge, daily verify); works on an existing spec too", false)
157
198
  .action(async (opts) => {
158
199
  const root = resolve(g().cwd);
@@ -192,10 +233,45 @@ export function buildProgram() {
192
233
  if (!opts.appStore && !opts.googlePlay)
193
234
  console.log(c.dim("Add stores.appStore.appId or stores.googlePlay.packageName, then run `appeeky-spec pull`."));
194
235
  }
195
- if (opts.pull && (opts.appStore || opts.googlePlay))
196
- await program.parseAsync(["pull"], { from: "user" });
197
- else if (g().json)
198
- printJson({ root, created: [SPEC_FILE, `${SPEC_DIR}/`, ...workflows] });
236
+ // Pull failures are reported and do not stop init: the spec is there, `pull` can run again later.
237
+ const pulled = opts.pull && (opts.appStore || opts.googlePlay) ? await pullListings(await load()) : undefined;
238
+ if (pulled?.errors.length)
239
+ process.exitCode = 1;
240
+ // The Google Play category, so `category pull` records its chart from the first day.
241
+ if (opts.googlePlay) {
242
+ const detected = await playCategory(opts.googlePlay).catch(() => undefined);
243
+ if (detected) {
244
+ // Into the spec as written above, so the file keeps only what init chose (no schema defaults).
245
+ spec.category = { ...spec.category, googlePlay: detected };
246
+ await writeSpec(root, spec);
247
+ if (!g().json)
248
+ console.log(`${c.green("Category")} Google Play ${detected}`);
249
+ }
250
+ }
251
+ // Targets, as the guided setup does: the ones given, or five suggested from the listing (or the
252
+ // name) and where the app already ranks on the App Store. --no-targets leaves them empty.
253
+ const country = opts.country.toLowerCase();
254
+ let targets = [];
255
+ let suggested = false;
256
+ if (typeof opts.targets === "string")
257
+ targets = [...new Set(opts.targets.split(",").map((x) => x.trim().toLowerCase()).filter(Boolean))];
258
+ else if (opts.targets !== false && (opts.appStore || opts.googlePlay)) {
259
+ const project = await load();
260
+ const appStoreId = opts.appStore && /^\d+$/.test(opts.appStore) ? opts.appStore : undefined;
261
+ const ranked = await suggestTargets(targetCandidates(project, 14, opts.name), appStoreId, country, itunesRankSource()).catch(() => []);
262
+ targets = ranked.map((r) => r.keyword);
263
+ suggested = true;
264
+ }
265
+ if (targets.length) {
266
+ spec.targets = { ...spec.targets, [country]: targets };
267
+ await writeSpec(root, spec);
268
+ if (!g().json)
269
+ console.log(`${c.green(suggested ? "Suggested" : "Added")} ${targets.length} targets for ${country.toUpperCase()}: ${targets.join(", ")}${suggested ? c.dim("\n A first guess from the name and listing: check them, and re-rank with `appeeky-spec suggest` once APPEEKY_API_KEY is set.") : ""}`);
270
+ }
271
+ else if (!g().json && opts.targets !== false)
272
+ console.log(c.dim(`No targets yet: add the searches to win under targets.${country} in ${SPEC_FILE}, or run \`appeeky-spec suggest\`.`));
273
+ if (g().json)
274
+ printJson({ root, created: [SPEC_FILE, `${SPEC_DIR}/`, ...workflows], targets: { [country]: targets }, ...(pulled ? { pulled: { written: pulled.written, errors: pulled.errors } } : {}) });
199
275
  });
200
276
  /**
201
277
  * The guided setup: find the app, make its folder and write the spec, check that the stores
@@ -413,7 +489,7 @@ export function buildProgram() {
413
489
  }
414
490
  const s = p.spinner();
415
491
  s.start(`Saving the key with the ${cli.bin} CLI`);
416
- const result = await runQuiet("npx", ["-y", "-p", cli.npmPackage, cli.bin, ...args], process.cwd());
492
+ const result = await runQuiet("npx", ["-y", "-p", npxPackage(store), cli.bin, ...args], process.cwd());
417
493
  if (result.code === 0) {
418
494
  s.stop(`Saved as "${account}" in the ${cli.bin} CLI's config (not in this repo)`);
419
495
  return true;
@@ -465,10 +541,13 @@ export function buildProgram() {
465
541
  program
466
542
  .command("doctor")
467
543
  .description("What is set up for this repo, what is missing, and how to fix it")
468
- .action(async () => {
544
+ .option("--offline", "Only look at what is set up; do not call the hosted gateways to check the connection", false)
545
+ .action(async (opts) => {
469
546
  const root = resolve(g().cwd);
470
547
  const project = await load().catch(() => null);
471
- const checks = diagnose(project?.root ?? root, project);
548
+ let checks = diagnose(project?.root ?? root, project);
549
+ if (project && !opts.offline)
550
+ checks = await probeConnections(project, checks);
472
551
  if (g().json)
473
552
  printJson({ checks });
474
553
  else {
@@ -486,24 +565,13 @@ export function buildProgram() {
486
565
  .addOption(storeOption())
487
566
  .option("--locale <locales...>", "Only these locales")
488
567
  .action(async (opts) => {
489
- const project = await load();
490
- const written = [];
491
- for (const store of configuredStores(project, opts.store)) {
492
- const handle = storeHandle(project, store, transportOverrides());
493
- if (!g().json)
494
- console.log(c.dim(`${storeLabel(store)}: pulling via ${handle.transport.label}…`));
495
- const state = await handle.adapter.pull();
496
- for (const [locale, listing] of Object.entries(state.listings)) {
497
- if (opts.locale && !opts.locale.includes(locale))
498
- continue;
499
- written.push({ store, locale, file: await writeListing(project.root, store, locale, listing) });
500
- }
501
- await recordPull(project.root, store, state.target);
502
- if (!g().json)
503
- console.log(`${storeLabel(store)}: ${Object.keys(state.listings).length} locales from ${state.target}`);
504
- }
568
+ const { written, errors, stores } = await pullListings(await load(), opts.store, opts.locale);
505
569
  if (g().json)
506
- printJson({ written });
570
+ printJson({ written, errors });
571
+ else if (errors.length && errors.length < stores.length)
572
+ console.error(c.dim(`Pulled ${stores.length - errors.length} of ${stores.length} stores; fix the one above and run \`appeeky-spec pull --store ${errors[0].store}\`.`));
573
+ if (errors.length)
574
+ process.exitCode = 1;
507
575
  });
508
576
  program
509
577
  .command("check")
@@ -956,7 +1024,10 @@ export function buildProgram() {
956
1024
  const a = api();
957
1025
  if (!a)
958
1026
  throw new Error("Set APPEEKY_API_KEY: posts come from the social accounts connected in Appeeky.");
959
- const data = await fetchSocial(a, { limit: Number(opts.limit) || 100 });
1027
+ const only = project.spec.social?.accounts;
1028
+ const data = await fetchSocial(a, { limit: Number(opts.limit) || 100, only });
1029
+ if (only?.length && !g().json)
1030
+ console.log(c.dim(`Only the accounts under social.accounts in ${SPEC_FILE}: ${only.join(", ")}`));
960
1031
  await saveSocial(project.root, data);
961
1032
  if (g().json) {
962
1033
  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 ?? [] });
@@ -1443,7 +1514,7 @@ export function buildProgram() {
1443
1514
  const a = needKey();
1444
1515
  const results = await pullVisibility(a, project, opts.country ? [opts.country.toLowerCase()] : undefined);
1445
1516
  if (g().json) {
1446
- printJson(results.map(({ data, ...r }) => ({ ...r, summary: data?.summary })));
1517
+ printJson(results.map(({ data, ...r }) => ({ ...r, summary: data?.summary, overall: data?.overall })));
1447
1518
  return;
1448
1519
  }
1449
1520
  for (const r of results) {
@@ -1459,8 +1530,13 @@ export function buildProgram() {
1459
1530
  }
1460
1531
  const s = d.summary;
1461
1532
  console.log(`${c.green("✓")} ${r.file.replace(project.root + "/", "")} ${c.green(`${s.winning} named`)} · ${c.yellow(`${s.weak} weak`)} · ${c.red(`${s.missing} missing`)}${s.noData ? c.dim(` · ${s.noData} not scanned yet`) : ""}`);
1533
+ if (d.overall)
1534
+ console.log(c.dim(` ${overallLine(d.overall)}`));
1462
1535
  for (const i of d.intents.filter((x) => x.status === "missing").slice(0, 3))
1463
1536
  console.log(` ${c.red("missing")} "${i.label}"${i.namedInstead ? c.dim(`: they name ${i.namedInstead.slice(0, 3).join(", ")}`) : ""}`);
1537
+ const gaps = d.sources.filter((s) => s.gap);
1538
+ if (gaps.length)
1539
+ console.log(` ${c.yellow("gaps")} ${c.dim(`cited for other apps, not for yours: ${gaps.slice(0, 4).map((s) => s.domain).join(", ")}`)}`);
1464
1540
  for (const ch of r.changes)
1465
1541
  console.log(` ${c.yellow("changed")} ${ch}`);
1466
1542
  if (d.fixes.length)
@@ -1575,12 +1651,14 @@ export function buildProgram() {
1575
1651
  results.push(r);
1576
1652
  }
1577
1653
  if (g().json) {
1578
- printJson(results.map(({ data, ...r }) => ({ ...r, summary: data.summary })));
1654
+ printJson(results.map(({ data, ...r }) => ({ ...r, summary: data.summary, overall: data.overall })));
1579
1655
  return;
1580
1656
  }
1581
1657
  for (const r of results) {
1582
1658
  const s = r.data.summary;
1583
1659
  console.log(`${c.green("✓")} ${r.file.replace(project.root + "/", "")} ${c.green(`${s.winning} named`)} · ${c.yellow(`${s.weak} weak`)} · ${c.red(`${s.missing} missing`)} ${c.dim(`$${r.costUsd.toFixed(2)}`)}`);
1660
+ if (r.data.overall)
1661
+ console.log(c.dim(` ${overallLine(r.data.overall)}`));
1584
1662
  for (const i of r.data.intents.filter((x) => x.status === "missing").slice(0, 3))
1585
1663
  console.log(` ${c.red("missing")} "${i.label}"${i.namedInstead ? c.dim(`: they name ${i.namedInstead.slice(0, 3).join(", ")}`) : ""}`);
1586
1664
  for (const ch of r.changes)
@@ -2215,11 +2293,21 @@ export async function run(argv = process.argv) {
2215
2293
  await program.parseAsync(argv);
2216
2294
  }
2217
2295
  catch (err) {
2218
- const message = err.message;
2296
+ const e = err;
2297
+ const debug = Boolean(process.env.APPEEKY_SPEC_DEBUG);
2298
+ // A TypeError and the like is a bug, not a message for the user: say so, with where it happened.
2299
+ const bug = !EXPECTED_ERRORS.has(e?.name ?? "Error");
2300
+ const frames = (e?.stack ?? "").split("\n").slice(1).map((l) => l.trim());
2301
+ const where = frames.find((l) => /appeeky-spec|@appeeky\/spec|\/src\/|\/dist\//.test(l)) ?? frames[0];
2219
2302
  if (program.opts().json)
2220
- printJson({ error: message });
2221
- else
2222
- console.error(c.red(message));
2303
+ printJson({ error: e?.message ?? String(err), ...(bug ? { bug: true, version: VERSION, where, ...(debug ? { stack: e?.stack } : {}) } : {}) });
2304
+ else {
2305
+ console.error(c.red(e?.message ?? String(err)));
2306
+ if (bug) {
2307
+ console.error(c.dim(`${e.name} in appeeky-spec ${VERSION}${where ? `, ${where}` : ""}.`));
2308
+ console.error(c.dim(debug ? (e.stack ?? "") : "This is a bug: run again with APPEEKY_SPEC_DEBUG=1 for the full stack, and report it with the command you ran."));
2309
+ }
2310
+ }
2223
2311
  process.exitCode = 1;
2224
2312
  }
2225
2313
  }
package/dist/data.d.ts CHANGED
@@ -8,7 +8,9 @@ import type { Project } from "./schema.js";
8
8
  *
9
9
  * They are private business data, so they go to .appeeky/data/ (gitignored) unless the
10
10
  * spec says `data: { commit: true }`, which writes them to appeeky/data/ instead.
11
- * Pulling again merges by date, so a scheduled pull keeps one growing file per source.
11
+ * Pulling again merges by date, so pulls in the same folder keep one growing file per source.
12
+ * The Docker routines start from a fresh clone, where .appeeky/ is empty: there a file grows
13
+ * only with `data: { commit: true }`, otherwise each run holds the last `--days`.
12
14
  */
13
15
  export declare function dataDir(project: Project): string;
14
16
  type Row = Record<string, string | number | null | undefined>;
package/dist/data.js CHANGED
@@ -10,7 +10,9 @@ import { rankAppIds } from "./verify.js";
10
10
  *
11
11
  * They are private business data, so they go to .appeeky/data/ (gitignored) unless the
12
12
  * spec says `data: { commit: true }`, which writes them to appeeky/data/ instead.
13
- * Pulling again merges by date, so a scheduled pull keeps one growing file per source.
13
+ * Pulling again merges by date, so pulls in the same folder keep one growing file per source.
14
+ * The Docker routines start from a fresh clone, where .appeeky/ is empty: there a file grows
15
+ * only with `data: { commit: true }`, otherwise each run holds the last `--days`.
14
16
  */
15
17
  export function dataDir(project) {
16
18
  return project.spec.data.commit ? join(project.root, SPEC_DIR, "data") : join(project.root, ".appeeky", "data");
package/dist/lint.d.ts CHANGED
@@ -9,6 +9,7 @@ export interface Issue {
9
9
  field?: string;
10
10
  message: string;
11
11
  }
12
+ export declare function functionWords(locale: string): Set<string>;
12
13
  export declare function lintLength(store: StoreId, locale: string, field: string, value: string | undefined): Issue[];
13
14
  export declare function lintAppStore(locale: string, listing: AppStoreListing): Issue[];
14
15
  export declare function lintGooglePlay(locale: string, listing: GooglePlayListing): Issue[];
package/dist/lint.js CHANGED
@@ -2,6 +2,25 @@ import { LIMITS } from "./limits.js";
2
2
  import { charLength, isEnglish, keywordEntries, singular, unique, words } from "./text.js";
3
3
  /** Words Apple already ignores or that buy nothing in the keyword field. */
4
4
  const APPLE_FILLER = new Set(["app", "apps", "the", "a", "an", "and", "or", "for", "with", "of", "iphone", "ipad"]);
5
+ /**
6
+ * Articles, prepositions and conjunctions per language. They carry no search on their own, so a
7
+ * name and subtitle that both need "de" or "and" to read naturally are not wasting index space.
8
+ */
9
+ const FUNCTION_WORDS = {
10
+ en: "a an the and or of for with to in on by at from",
11
+ es: "de del la el los las y o en con para por un una al a",
12
+ pt: "de do da dos das e o a os as em com para por um uma no na",
13
+ fr: "de du des la le les et ou en avec pour par un une au aux à l d",
14
+ it: "di del della dei delle e o il lo la i gli le in con per un una al a da",
15
+ de: "der die das und oder mit für von zu im in am an auf ein eine den dem des",
16
+ nl: "de het een en of met voor van in op",
17
+ tr: "ve ile için bir da de",
18
+ pl: "i w z na do dla o",
19
+ sv: "och med för av i på en ett",
20
+ };
21
+ export function functionWords(locale) {
22
+ return new Set((FUNCTION_WORDS[locale.split("-")[0].toLowerCase()] ?? "").split(" ").filter(Boolean));
23
+ }
5
24
  /** Google Play's metadata policy rejects these in the title. */
6
25
  const PLAY_TITLE_BANNED = [/\bbest\b/i, /#\s?1\b/, /\btop\b/i, /\bfree\b/i, /\bno\.?\s?1\b/i, /\bsale\b/i, /\bdiscount\b/i];
7
26
  export function lintLength(store, locale, field, value) {
@@ -30,7 +49,8 @@ export function lintAppStore(locale, listing) {
30
49
  }
31
50
  const nameWords = new Set(words(listing.name));
32
51
  const subtitleWords = words(listing.subtitle);
33
- const repeatedInSubtitle = unique(subtitleWords.filter((w) => nameWords.has(w)));
52
+ const stop = functionWords(locale);
53
+ const repeatedInSubtitle = unique(subtitleWords.filter((w) => nameWords.has(w) && !stop.has(w)));
34
54
  if (repeatedInSubtitle.length > 0) {
35
55
  at("warning", "subtitle/repeats-name", "subtitle", `Subtitle repeats ${quoteList(repeatedInSubtitle)} from the name. Each word is indexed once, so use the space for a new word.`);
36
56
  }
@@ -52,7 +72,7 @@ export function lintAppStore(locale, listing) {
52
72
  }
53
73
  const keywordWords = entries.flatMap((e) => words(e));
54
74
  const titled = new Set([...nameWords, ...subtitleWords]);
55
- const alreadyIndexed = unique(keywordWords.filter((w) => titled.has(w)));
75
+ const alreadyIndexed = unique(keywordWords.filter((w) => titled.has(w) && !stop.has(w)));
56
76
  if (alreadyIndexed.length > 0) {
57
77
  at("warning", "keywords/duplicate-of-name", "keywords", `${quoteList(alreadyIndexed)} already ${alreadyIndexed.length === 1 ? "appears" : "appear"} in the name or subtitle, so the keyword field does not need ${alreadyIndexed.length === 1 ? "it" : "them"}.`);
58
78
  }
@@ -60,11 +80,12 @@ export function lintAppStore(locale, listing) {
60
80
  if (repeatedWords.length > 0) {
61
81
  at("info", "keywords/repeated-word", "keywords", `${quoteList(repeatedWords)} ${repeatedWords.length === 1 ? "is" : "are"} written more than once. Single words combine with each other, so phrases rarely need repeating.`);
62
82
  }
83
+ // Filler in any language: the function words above, plus Apple's English ones.
84
+ const filler = unique(keywordWords.filter((w) => stop.has(w) || (isEnglish(locale) && APPLE_FILLER.has(w))));
85
+ if (filler.length > 0) {
86
+ at("info", "keywords/filler", "keywords", `${quoteList(filler)} add little in the keyword field.`);
87
+ }
63
88
  if (isEnglish(locale)) {
64
- const filler = unique(keywordWords.filter((w) => APPLE_FILLER.has(w)));
65
- if (filler.length > 0) {
66
- at("info", "keywords/filler", "keywords", `${quoteList(filler)} add little in the keyword field.`);
67
- }
68
89
  const all = unique([...titled, ...keywordWords]);
69
90
  const plurals = all.filter((w) => singular(w) !== w && all.includes(singular(w)));
70
91
  if (plurals.length > 0) {
package/dist/schema.d.ts CHANGED
@@ -338,6 +338,19 @@ export declare const specFileSchema: z.ZodObject<{
338
338
  keywords?: Record<string, string[]> | undefined;
339
339
  device?: "mobile" | "desktop" | undefined;
340
340
  }>>;
341
+ /**
342
+ * Which of the social accounts connected in Appeeky belong to this app. Appeeky lists every
343
+ * account on the key's account, so with several apps (or a company account next to the app's)
344
+ * name this app's here: an id from accounts.yaml, a handle (`@saiko`, `u/name`) or
345
+ * `platform:@handle`. `social pull` keeps only these, so drafts can only go to them.
346
+ */
347
+ social: z.ZodOptional<z.ZodObject<{
348
+ accounts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
349
+ }, "strict", z.ZodTypeAny, {
350
+ accounts?: string[] | undefined;
351
+ }, {
352
+ accounts?: string[] | undefined;
353
+ }>>;
341
354
  /** Rank in the app's category chart (top 100), recorded daily by `category pull`. */
342
355
  category: z.ZodOptional<z.ZodObject<{
343
356
  /** App Store genre id, e.g. "6013" for Health & Fitness; read from the app when left out. */
@@ -634,6 +647,9 @@ export declare const specFileSchema: z.ZodObject<{
634
647
  keywords?: Record<string, string[]> | undefined;
635
648
  device?: "mobile" | "desktop" | undefined;
636
649
  } | undefined;
650
+ social?: {
651
+ accounts?: string[] | undefined;
652
+ } | undefined;
637
653
  category?: {
638
654
  appStore?: string | undefined;
639
655
  googlePlay?: string | undefined;
@@ -710,6 +726,9 @@ export declare const specFileSchema: z.ZodObject<{
710
726
  keywords?: Record<string, string[]> | undefined;
711
727
  device?: "mobile" | "desktop" | undefined;
712
728
  } | undefined;
729
+ social?: {
730
+ accounts?: string[] | undefined;
731
+ } | undefined;
713
732
  category?: {
714
733
  appStore?: string | undefined;
715
734
  googlePlay?: string | undefined;
package/dist/schema.js CHANGED
@@ -180,6 +180,16 @@ export const specFileSchema = z
180
180
  })
181
181
  .strict()
182
182
  .optional(),
183
+ /**
184
+ * Which of the social accounts connected in Appeeky belong to this app. Appeeky lists every
185
+ * account on the key's account, so with several apps (or a company account next to the app's)
186
+ * name this app's here: an id from accounts.yaml, a handle (`@saiko`, `u/name`) or
187
+ * `platform:@handle`. `social pull` keeps only these, so drafts can only go to them.
188
+ */
189
+ social: z
190
+ .object({ accounts: z.array(z.string().min(1)).min(1).optional() })
191
+ .strict()
192
+ .optional(),
183
193
  /** Rank in the app's category chart (top 100), recorded daily by `category pull`. */
184
194
  category: z
185
195
  .object({
@@ -3,7 +3,7 @@ import { existsSync } from "node:fs";
3
3
  import { mkdir, readFile, writeFile } from "node:fs/promises";
4
4
  import { join } from "node:path";
5
5
  import { SPEC_DIR } from "./files.js";
6
- import { defaultRunner, onPath, STORE_CLIS } from "./transport.js";
6
+ import { defaultRunner, npxPackage, onPath, STORE_CLIS } from "./transport.js";
7
7
  /**
8
8
  * Apple Search Ads on your own API key, no Appeeky account: the app's campaigns, spend and installs
9
9
  * per day, and the keywords and search terms that brought installs, in appeeky/search-ads/.
@@ -113,7 +113,7 @@ export function cliRequest(options = {}) {
113
113
  const run = async (args) => {
114
114
  const argv = ["--json", ...(options.account ? ["--account", options.account] : []), "search-ads", ...args];
115
115
  const useNpx = options.useNpx ?? !onPath(cli.bin);
116
- const [command, full] = useNpx ? ["npx", ["-y", "-p", cli.npmPackage, cli.bin, ...argv]] : [cli.bin, argv];
116
+ const [command, full] = useNpx ? ["npx", ["-y", "-p", npxPackage("app-store"), cli.bin, ...argv]] : [cli.bin, argv];
117
117
  let r;
118
118
  try {
119
119
  r = await (options.runner ?? defaultRunner)(command, full);
package/dist/setup.d.ts CHANGED
@@ -40,6 +40,13 @@ export interface DoctorCheck {
40
40
  export declare function savedAccountsFile(store: StoreId, env?: NodeJS.ProcessEnv): string;
41
41
  /** Names of the accounts saved with the store CLI, if any. */
42
42
  export declare function savedAccounts(store: StoreId, env?: NodeJS.ProcessEnv): string[];
43
+ /**
44
+ * `diagnose` only sees which keys are set. This asks each store reached through the hosted
45
+ * gateway for one read, so a key that is valid but has no store connected (or the wrong
46
+ * account's key) shows up as a failure instead of "Ready". Local CLIs are not called: that
47
+ * can take a minute through npx; `pull` shows their errors.
48
+ */
49
+ export declare function probeConnections(project: Project, checks: DoctorCheck[], env?: NodeJS.ProcessEnv, fetcher?: typeof fetch, timeoutMs?: number): Promise<DoctorCheck[]>;
43
50
  /** What is set up for this repo, and what is missing. Works without a spec (it says so). */
44
51
  export declare function diagnose(root: string, project: Project | null, env?: NodeJS.ProcessEnv, nodeVersion?: string): DoctorCheck[];
45
52
  export {};