@appeeky/spec 0.9.0 → 0.10.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 +4 -2
- package/dist/alerts.d.ts +10 -0
- package/dist/alerts.js +25 -0
- package/dist/cli.js +56 -7
- package/dist/schema.d.ts +26 -6
- package/dist/schema.js +3 -1
- package/dist/setup.d.ts +8 -0
- package/dist/setup.js +38 -0
- package/dist/social.d.ts +56 -1
- package/dist/social.js +117 -4
- package/package.json +1 -1
- package/skills/appeeky-spec-automation/SKILL.md +2 -2
- package/skills/appeeky-spec-server/SKILL.md +2 -1
- package/skills/appeeky-spec-social/SKILL.md +14 -5
package/README.md
CHANGED
|
@@ -143,7 +143,7 @@ A field you leave out of a listing file is not managed by the spec: it is never
|
|
|
143
143
|
| `experiment add\|list\|close` | Track growth experiments outside the listing (screenshots, UGC, ads, pricing) with one metric and a check date. |
|
|
144
144
|
| `screenshots pull\|check` | Download the live App Store screenshots into `appeeky/screenshots/` and check their sizes. |
|
|
145
145
|
| `report` | Markdown for a pull request: listing changes, check results and coverage against `--base`. |
|
|
146
|
-
| `social pull\|check\|push` | Organic social media through the accounts connected in Appeeky (X, Instagram, TikTok, LinkedIn, Pinterest, Reddit, YouTube, Threads, Facebook, Bluesky): `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`. |
|
|
146
|
+
| `social pull\|check\|push\|connect` | Organic social media through the accounts connected in Appeeky (X, Instagram, TikTok, LinkedIn, Pinterest, Reddit, YouTube, Threads, Facebook, Bluesky): `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; `connect <platform>` prints the sign-in link to connect or reconnect an account and waits until it works. Needs `APPEEKY_API_KEY`. |
|
|
147
147
|
| `social comments\|reply\|hide\|like\|delete-comment` | Comments on your posts: `comments` lists them (`--unanswered`, `--account`, `--post`, `--limit`); `reply <id> "<message>"` answers from the account it is on, after checking the platform's reply limit; `hide <id>` (`--unhide`), `like <id>`; `delete-comment <id>` asks first, or needs `--yes` outside a terminal. Needs `APPEEKY_API_KEY`. |
|
|
148
148
|
| `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`. |
|
|
149
149
|
| `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`. |
|
|
@@ -358,7 +358,7 @@ What each platform takes:
|
|
|
358
358
|
| Reddit | up to 40,000 characters (the body); a subreddit in `reddit:` | optional |
|
|
359
359
|
| Instagram, TikTok, Pinterest | 2,200, 2,200, 500 characters | at least one image or video |
|
|
360
360
|
|
|
361
|
-
`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 or video, too many images or videos for the platform, images and a video mixed where the platform does not allow it, a time in the past, 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) YouTube's (exactly one video, a title over 100 characters) and Reddit's (a subreddit, a title over 300 characters). Media types are read from the URL's file extension. `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.
|
|
361
|
+
`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 or video, too many images or videos for the platform, images and a video mixed where the platform does not allow it, a time in the past, 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) YouTube's (exactly one video, a title over 100 characters) and Reddit's (a subreddit, a title over 300 characters). Media types are read from the URL's file extension. `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. When a platform drops an account (a revoked permission, a changed password), Appeeky marks it `needsReconnect`: `social pull`, `doctor`, the `social-account` alert and `social check` say so, and `social connect <platform>` gives the sign-in link (and one for the phone) without the dashboard, then waits until the account works. Appeeky keeps the tokens and refreshes them; a sign-in is only needed when the platform refuses that. Social media needs the Startup plan or above in Appeeky; a persona needs a look (reference images) before it can make clips.
|
|
362
362
|
|
|
363
363
|
### Comments
|
|
364
364
|
|
|
@@ -519,6 +519,7 @@ The daily run writes the numbers; `alerts` tells you when one of them needs a pe
|
|
|
519
519
|
| `visibility-drop` | `appeeky/visibility/changes.md` | in the last 3 days the assistants named the app less for an intent (critical when no longer at all) or stopped citing its site |
|
|
520
520
|
| `search-drop` | `appeeky/seo/daily.csv` | Search Console clicks per day over the last 7 days fell 30% against the 7 days before (with 20+ clicks before); critical at 60% |
|
|
521
521
|
| `late-check` | `appeeky/loops.md` (releases and experiments) | a check is 2+ days past its date with no result; critical at 7 |
|
|
522
|
+
| `social-account` | `appeeky/social/accounts.yaml` (from the last `social pull`, if under 7 days old) | an account needs reconnecting or was turned off (critical), or a `social.accounts` entry matches no connected account |
|
|
522
523
|
|
|
523
524
|
```bash
|
|
524
525
|
npx @appeeky/spec alerts # a table
|
|
@@ -549,6 +550,7 @@ alerts:
|
|
|
549
550
|
visibility-drop: { days: 3 }
|
|
550
551
|
search-drop: { days: 7, drop: 0.3, min: 20 }
|
|
551
552
|
late-check: { days: 2 }
|
|
553
|
+
social-account: { days: 7 } # how old the last social pull may be
|
|
552
554
|
```
|
|
553
555
|
|
|
554
556
|
Target ranks are recorded at each push and on its day-7 and day-14 checks, so `rank-drop` speaks up around releases; between releases the category chart, reviews, competitors and Search Console carry the daily signal.
|
package/dist/alerts.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type ReleaseRecord } from "./history.js";
|
|
|
3
3
|
import { type Loop } from "./loops.js";
|
|
4
4
|
import { type Review } from "./reviews.js";
|
|
5
5
|
import type { AlertKind, Project, SpecFile } from "./schema.js";
|
|
6
|
+
import { type SocialAccount } from "./social.js";
|
|
6
7
|
export type AlertSeverity = "warn" | "critical";
|
|
7
8
|
export interface Alert {
|
|
8
9
|
/** Stable id: the same problem keeps the same key from one day to the next. */
|
|
@@ -63,6 +64,15 @@ export declare function searchDrops(rows: Array<{
|
|
|
63
64
|
clicks: number;
|
|
64
65
|
}>, cfg: Config["search-drop"], now: Date): Alert[];
|
|
65
66
|
export declare function lateChecks(loops: Loop[], cfg: Config["late-check"], now: Date): Alert[];
|
|
67
|
+
/**
|
|
68
|
+
* Accounts from the last social pull that stopped working, and social.accounts entries no
|
|
69
|
+
* connected account matches. A broken account is critical: posts the repo approved do not go
|
|
70
|
+
* out on it, and its comments and followers stop coming in.
|
|
71
|
+
*/
|
|
72
|
+
export declare function socialAccountAlerts(file: {
|
|
73
|
+
accounts: SocialAccount[];
|
|
74
|
+
checkedAt?: string;
|
|
75
|
+
}, only: string[] | undefined, cfg: Config["social-account"], now: Date): Alert[];
|
|
66
76
|
/** Every alert the repo's files show today, critical first. Kinds under `alerts.off` are left out. */
|
|
67
77
|
export declare function collectAlerts(project: Project, now?: Date): Promise<Alert[]>;
|
|
68
78
|
export interface AlertState {
|
package/dist/alerts.js
CHANGED
|
@@ -11,6 +11,7 @@ import { collectLoops } from "./loops.js";
|
|
|
11
11
|
import { readReviews } from "./reviews.js";
|
|
12
12
|
import { ALERT_KINDS } from "./schema.js";
|
|
13
13
|
import { seoDir } from "./seo.js";
|
|
14
|
+
import { accountProblems, readAccountsFile } from "./social.js";
|
|
14
15
|
import { normalize } from "./text.js";
|
|
15
16
|
import { visibilityChangesFile } from "./visibility.js";
|
|
16
17
|
const DAY = 86_400_000;
|
|
@@ -320,6 +321,29 @@ export function lateChecks(loops, cfg, now) {
|
|
|
320
321
|
return out;
|
|
321
322
|
}
|
|
322
323
|
// ── All of them ─────────────────────────────────────────────────────────────
|
|
324
|
+
// ── Social accounts ─────────────────────────────────────────────────────────
|
|
325
|
+
/**
|
|
326
|
+
* Accounts from the last social pull that stopped working, and social.accounts entries no
|
|
327
|
+
* connected account matches. A broken account is critical: posts the repo approved do not go
|
|
328
|
+
* out on it, and its comments and followers stop coming in.
|
|
329
|
+
*/
|
|
330
|
+
export function socialAccountAlerts(file, only, cfg, now) {
|
|
331
|
+
if (file.checkedAt && now.getTime() - Date.parse(file.checkedAt) > cfg.days * DAY)
|
|
332
|
+
return [];
|
|
333
|
+
if (!file.accounts.length && !only?.length)
|
|
334
|
+
return [];
|
|
335
|
+
// Without a time (a file from before 0.10), only the accounts' own state counts, not missing ones.
|
|
336
|
+
return accountProblems(file.accounts, file.checkedAt ? (only ?? []) : []).map((p) => ({
|
|
337
|
+
key: `social-account:${p.platform}:${p.account?.id ?? p.ref}`,
|
|
338
|
+
kind: "social-account",
|
|
339
|
+
severity: p.account ? "critical" : "warn",
|
|
340
|
+
title: p.account ? `${p.message.replace(/ \(.*\)$/, "")}` : p.message,
|
|
341
|
+
numbers: p.account?.lastError ? `Last error: ${p.account.lastError}` : p.account ? "No approved post goes out on it, and its comments and followers stop coming in." : "Nothing is read or posted for it.",
|
|
342
|
+
window: file.checkedAt ? `social pull on ${file.checkedAt.slice(0, 10)}` : "last social pull",
|
|
343
|
+
source: `${SPEC_DIR}/social/accounts.yaml`,
|
|
344
|
+
next: p.fix,
|
|
345
|
+
}));
|
|
346
|
+
}
|
|
323
347
|
const SEVERITY_ORDER = { critical: 0, warn: 1 };
|
|
324
348
|
/** Every alert the repo's files show today, critical first. Kinds under `alerts.off` are left out. */
|
|
325
349
|
export async function collectAlerts(project, now = new Date()) {
|
|
@@ -336,6 +360,7 @@ export async function collectAlerts(project, now = new Date()) {
|
|
|
336
360
|
...(on("visibility-drop") ? visibilityDrops(await readVisibilityChanges(root), cfg["visibility-drop"], now) : []),
|
|
337
361
|
...(on("search-drop") ? searchDrops(await readSearchDaily(root), cfg["search-drop"], now) : []),
|
|
338
362
|
...(on("late-check") ? lateChecks(await collectLoops(root, now), cfg["late-check"], now) : []),
|
|
363
|
+
...(on("social-account") ? socialAccountAlerts(await readAccountsFile(root), project.spec.social?.accounts, cfg["social-account"], now) : []),
|
|
339
364
|
];
|
|
340
365
|
return out.sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity] || ALERT_KINDS.indexOf(a.kind) - ALERT_KINDS.indexOf(b.kind));
|
|
341
366
|
}
|
package/dist/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ import { COFOUNDER_COMMAND, installAgents, parseTargets, TARGET_DIRS } from "./a
|
|
|
10
10
|
import { attributionClient, attributionClients, attributionMetricSource, createExperimentLink, hasClients, IOS_LINK_NOTE, iosOnlyLink, isClient, linkStore, linkValueReader } from "./attribution.js";
|
|
11
11
|
import { alertsMarkdown, alertsText, collectAlerts, githubRepo, markNew, nextAlertState, postWebhook, readAlertState, syncIssue, writeAlertState } from "./alerts.js";
|
|
12
12
|
import { pullCompetitors, similarApps } from "./competitors.js";
|
|
13
|
-
import { commentPlatform, deleteComment, draftIssues, fetchSocial, hideComment, likeComment, listComments, readAccounts, readDrafts, replyToComment, resolveAccounts, saveSocial, sendDraft } from "./social.js";
|
|
13
|
+
import { accountLabel, accountMatches, accountProblems, connectLink, listAccountRows, toAccount, waitForConnection, 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
16
|
import { categoryFile, categoryMetricSource, categoryPlans, playCategory, chartSources, previousRank, readCategoryHistory, readCategoryRanks, saveCategoryRanks } from "./category.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, probeConnections, playPackageExists, suggestTargets, targetCandidates, WORKFLOWS } from "./setup.js";
|
|
39
|
+
import { diagnose, findApps, probeConnections, probeSocial, 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";
|
|
@@ -137,7 +137,7 @@ export const VERSION = (() => {
|
|
|
137
137
|
}
|
|
138
138
|
})();
|
|
139
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"]);
|
|
140
|
+
const EXPECTED_ERRORS = new Set(["Error", "SpecError", "TransportError", "AppeekyApiError", "CommanderError", "ConnectUnavailableError"]);
|
|
141
141
|
export function buildProgram() {
|
|
142
142
|
const program = new Command()
|
|
143
143
|
.name("appeeky-spec")
|
|
@@ -547,14 +547,15 @@ export function buildProgram() {
|
|
|
547
547
|
const project = await load().catch(() => null);
|
|
548
548
|
let checks = diagnose(project?.root ?? root, project);
|
|
549
549
|
if (project && !opts.offline)
|
|
550
|
-
checks = await probeConnections(project, checks);
|
|
550
|
+
checks = await probeSocial(project, await probeConnections(project, checks));
|
|
551
551
|
if (g().json)
|
|
552
552
|
printJson({ checks });
|
|
553
553
|
else {
|
|
554
554
|
printChecks(checks);
|
|
555
555
|
const fails = checks.filter((x) => x.status === "fail").length;
|
|
556
|
-
const
|
|
557
|
-
|
|
556
|
+
const look = checks.filter((x) => x.status === "warn" && x.attention).length;
|
|
557
|
+
const warns = checks.filter((x) => x.status === "warn" && !x.attention).length;
|
|
558
|
+
console.log(`\n${fails ? c.red(`${fails} to fix`) : c.green("Ready")}${look ? c.yellow(` · ${look} to look at`) : ""}${warns ? c.dim(` · ${warns} optional`) : ""}`);
|
|
558
559
|
}
|
|
559
560
|
if (checks.some((x) => x.status === "fail"))
|
|
560
561
|
process.exitCode = 1;
|
|
@@ -1030,7 +1031,7 @@ export function buildProgram() {
|
|
|
1030
1031
|
console.log(c.dim(`Only the accounts under social.accounts in ${SPEC_FILE}: ${only.join(", ")}`));
|
|
1031
1032
|
await saveSocial(project.root, data);
|
|
1032
1033
|
if (g().json) {
|
|
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 ?? [] });
|
|
1034
|
+
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 ?? [], problems: accountProblems(data.accounts, only).map(({ account, ...p }) => ({ ...p, ...(account ? { account: account.id } : {}) })) });
|
|
1034
1035
|
return;
|
|
1035
1036
|
}
|
|
1036
1037
|
console.log(`${c.bold("Accounts")} ${data.accounts.map((x) => `${x.platform} (${x.name})`).join(", ") || c.dim("none connected")}`);
|
|
@@ -1039,9 +1040,57 @@ export function buildProgram() {
|
|
|
1039
1040
|
console.log(`${c.bold("Comments")} ${data.comments.length}`);
|
|
1040
1041
|
for (const w of data.warnings ?? [])
|
|
1041
1042
|
console.log(`${c.yellow("warn ")} ${w}`);
|
|
1043
|
+
for (const p of accountProblems(data.accounts, only))
|
|
1044
|
+
console.log(`${c.red("fix ")} ${p.message}\n ${c.dim(p.fix)}`);
|
|
1042
1045
|
const files = ["accounts.yaml", "posts.jsonl", data.nativePosts && "native-posts.jsonl", data.comments && "comments.jsonl", data.insights && "insights.yaml", "summary.md"].filter(Boolean);
|
|
1043
1046
|
console.log(c.dim(`Written to appeeky/social/: ${files.join(", ")}.`));
|
|
1044
1047
|
});
|
|
1048
|
+
social
|
|
1049
|
+
.command("connect")
|
|
1050
|
+
.description("Connect a social account, or reconnect one that stopped working, without the Appeeky dashboard: prints the sign-in link and waits until it lands")
|
|
1051
|
+
.argument("<platform>", "tiktok, instagram, pinterest, youtube, twitter, linkedin, …")
|
|
1052
|
+
.option("--account <account>", "The account to reconnect when the platform has several: a handle (@saikoaiapp) or its id")
|
|
1053
|
+
.option("--no-wait", "Only print the link; do not wait for the sign-in")
|
|
1054
|
+
.option("--timeout <seconds>", "How long to wait for the sign-in", "600")
|
|
1055
|
+
.action(async (platform, opts) => {
|
|
1056
|
+
const a = api();
|
|
1057
|
+
if (!a)
|
|
1058
|
+
throw new Error("Set APPEEKY_API_KEY: the account is connected to your Appeeky account, which keeps its tokens and refreshes them.");
|
|
1059
|
+
const before = await listAccountRows(a);
|
|
1060
|
+
const onPlatform = before.map(toAccount).filter((x) => x.platform.toLowerCase() === platform.toLowerCase() || (platform.toLowerCase() === "x" && x.platform === "twitter"));
|
|
1061
|
+
let target = opts.account ? onPlatform.find((x) => accountMatches(x, [opts.account, `${x.platform}:${opts.account}`])) : undefined;
|
|
1062
|
+
if (opts.account && !target)
|
|
1063
|
+
throw new Error(`No ${platform} account ${opts.account} is connected (${onPlatform.map(accountLabel).join(", ") || "none"}). Leave out --account to connect a new one.`);
|
|
1064
|
+
// One broken account on the platform: that is the one to reconnect.
|
|
1065
|
+
if (!target && onPlatform.filter((x) => !x.active).length === 1)
|
|
1066
|
+
target = onPlatform.find((x) => !x.active);
|
|
1067
|
+
const link = await connectLink(a, platform, target?.id);
|
|
1068
|
+
if (g().json && !opts.wait) {
|
|
1069
|
+
printJson({ platform, account: target?.id ?? null, ...link });
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
if (!g().json) {
|
|
1073
|
+
console.log(`${c.bold(target ? `Reconnect ${platform} ${accountLabel(target)}` : `Connect ${platform}`)}${target?.problem ? c.dim(` (${target.problem})`) : ""}`);
|
|
1074
|
+
console.log(` Sign in: ${link.url}`);
|
|
1075
|
+
if (link.phoneUrl)
|
|
1076
|
+
console.log(` On your phone: ${link.phoneUrl}`);
|
|
1077
|
+
if (link.expiresAt)
|
|
1078
|
+
console.log(c.dim(` The link works until ${link.expiresAt}.`));
|
|
1079
|
+
}
|
|
1080
|
+
if (!opts.wait)
|
|
1081
|
+
return;
|
|
1082
|
+
if (!g().json)
|
|
1083
|
+
console.log(c.dim(`Waiting for the sign-in (up to ${opts.timeout}s; Ctrl+C to stop, the link still works)…`));
|
|
1084
|
+
const done = await waitForConnection(a, platform, before, { timeoutMs: (Number(opts.timeout) || 600) * 1000, accountId: target?.id });
|
|
1085
|
+
if (g().json)
|
|
1086
|
+
printJson({ platform, connected: done ? { id: done.id, name: done.name } : null, ...link });
|
|
1087
|
+
else if (done)
|
|
1088
|
+
console.log(c.green(`Connected: ${done.platform} ${accountLabel(done)}.`) + c.dim(" Run `appeeky-spec social pull` to write it to appeeky/social/."));
|
|
1089
|
+
else
|
|
1090
|
+
console.log(c.yellow("No sign-in yet. The link still works: run this again to wait, or `appeeky-spec doctor` to check later."));
|
|
1091
|
+
if (!done)
|
|
1092
|
+
process.exitCode = 1;
|
|
1093
|
+
});
|
|
1045
1094
|
social
|
|
1046
1095
|
.command("check")
|
|
1047
1096
|
.description("Check the drafts in appeeky/social/drafts/: which account each goes to, length, media, TikTok and YouTube options, time")
|
package/dist/schema.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type TransportMode = z.infer<typeof transportMode>;
|
|
|
9
9
|
export declare const CHARTS: readonly ["top-free", "top-paid", "top-grossing"];
|
|
10
10
|
export type Chart = (typeof CHARTS)[number];
|
|
11
11
|
/** What `alerts` looks for in the files the daily run writes. */
|
|
12
|
-
export declare const ALERT_KINDS: readonly ["rank-drop", "release-lost", "category-drop", "low-ratings", "competitor-change", "visibility-drop", "search-drop", "late-check"];
|
|
12
|
+
export declare const ALERT_KINDS: readonly ["rank-drop", "release-lost", "category-drop", "low-ratings", "competitor-change", "visibility-drop", "search-drop", "late-check", "social-account"];
|
|
13
13
|
export type AlertKind = (typeof ALERT_KINDS)[number];
|
|
14
14
|
/** `appeeky.spec.yaml`: who the app is, where it ships, and what it should be found for. */
|
|
15
15
|
export declare const specFileSchema: z.ZodObject<{
|
|
@@ -378,7 +378,7 @@ export declare const specFileSchema: z.ZodObject<{
|
|
|
378
378
|
*/
|
|
379
379
|
alerts: z.ZodDefault<z.ZodObject<{
|
|
380
380
|
/** Kinds to leave out, e.g. [competitor-change]. */
|
|
381
|
-
off: z.ZodDefault<z.ZodArray<z.ZodEnum<["rank-drop", "release-lost", "category-drop", "low-ratings", "competitor-change", "visibility-drop", "search-drop", "late-check"]>, "many">>;
|
|
381
|
+
off: z.ZodDefault<z.ZodArray<z.ZodEnum<["rank-drop", "release-lost", "category-drop", "low-ratings", "competitor-change", "visibility-drop", "search-drop", "late-check", "social-account"]>, "many">>;
|
|
382
382
|
/** A target fell this many places between its last two recorded checks (critical: twice that, or a top-10 target out of the top 20). */
|
|
383
383
|
"rank-drop": z.ZodDefault<z.ZodObject<{
|
|
384
384
|
places: z.ZodDefault<z.ZodNumber>;
|
|
@@ -458,6 +458,14 @@ export declare const specFileSchema: z.ZodObject<{
|
|
|
458
458
|
}, {
|
|
459
459
|
days?: number | undefined;
|
|
460
460
|
}>>;
|
|
461
|
+
/** A social account under social.accounts stopped working (needs reconnecting, turned off) or is not connected: read from the last social pull, if it is under `days` old. */
|
|
462
|
+
"social-account": z.ZodDefault<z.ZodObject<{
|
|
463
|
+
days: z.ZodDefault<z.ZodNumber>;
|
|
464
|
+
}, "strict", z.ZodTypeAny, {
|
|
465
|
+
days: number;
|
|
466
|
+
}, {
|
|
467
|
+
days?: number | undefined;
|
|
468
|
+
}>>;
|
|
461
469
|
}, "strict", z.ZodTypeAny, {
|
|
462
470
|
"rank-drop": {
|
|
463
471
|
places: number;
|
|
@@ -488,7 +496,10 @@ export declare const specFileSchema: z.ZodObject<{
|
|
|
488
496
|
"late-check": {
|
|
489
497
|
days: number;
|
|
490
498
|
};
|
|
491
|
-
|
|
499
|
+
"social-account": {
|
|
500
|
+
days: number;
|
|
501
|
+
};
|
|
502
|
+
off: ("rank-drop" | "release-lost" | "category-drop" | "low-ratings" | "competitor-change" | "visibility-drop" | "search-drop" | "late-check" | "social-account")[];
|
|
492
503
|
}, {
|
|
493
504
|
"rank-drop"?: {
|
|
494
505
|
places?: number | undefined;
|
|
@@ -519,7 +530,10 @@ export declare const specFileSchema: z.ZodObject<{
|
|
|
519
530
|
"late-check"?: {
|
|
520
531
|
days?: number | undefined;
|
|
521
532
|
} | undefined;
|
|
522
|
-
|
|
533
|
+
"social-account"?: {
|
|
534
|
+
days?: number | undefined;
|
|
535
|
+
} | undefined;
|
|
536
|
+
off?: ("rank-drop" | "release-lost" | "category-drop" | "low-ratings" | "competitor-change" | "visibility-drop" | "search-drop" | "late-check" | "social-account")[] | undefined;
|
|
523
537
|
}>>;
|
|
524
538
|
/** Who the app is for. Experiments, screenshots and UGC refer to these by id. */
|
|
525
539
|
personas: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
@@ -613,7 +627,10 @@ export declare const specFileSchema: z.ZodObject<{
|
|
|
613
627
|
"late-check": {
|
|
614
628
|
days: number;
|
|
615
629
|
};
|
|
616
|
-
|
|
630
|
+
"social-account": {
|
|
631
|
+
days: number;
|
|
632
|
+
};
|
|
633
|
+
off: ("rank-drop" | "release-lost" | "category-drop" | "low-ratings" | "competitor-change" | "visibility-drop" | "search-drop" | "late-check" | "social-account")[];
|
|
617
634
|
};
|
|
618
635
|
personas: {
|
|
619
636
|
name: string;
|
|
@@ -765,7 +782,10 @@ export declare const specFileSchema: z.ZodObject<{
|
|
|
765
782
|
"late-check"?: {
|
|
766
783
|
days?: number | undefined;
|
|
767
784
|
} | undefined;
|
|
768
|
-
|
|
785
|
+
"social-account"?: {
|
|
786
|
+
days?: number | undefined;
|
|
787
|
+
} | undefined;
|
|
788
|
+
off?: ("rank-drop" | "release-lost" | "category-drop" | "low-ratings" | "competitor-change" | "visibility-drop" | "search-drop" | "late-check" | "social-account")[] | undefined;
|
|
769
789
|
} | undefined;
|
|
770
790
|
personas?: {
|
|
771
791
|
name: string;
|
package/dist/schema.js
CHANGED
|
@@ -67,7 +67,7 @@ const aiIntent = z
|
|
|
67
67
|
/** Store charts a category rank is read from. */
|
|
68
68
|
export const CHARTS = ["top-free", "top-paid", "top-grossing"];
|
|
69
69
|
/** What `alerts` looks for in the files the daily run writes. */
|
|
70
|
-
export const ALERT_KINDS = ["rank-drop", "release-lost", "category-drop", "low-ratings", "competitor-change", "visibility-drop", "search-drop", "late-check"];
|
|
70
|
+
export const ALERT_KINDS = ["rank-drop", "release-lost", "category-drop", "low-ratings", "competitor-change", "visibility-drop", "search-drop", "late-check", "social-account"];
|
|
71
71
|
/** `appeeky.spec.yaml`: who the app is, where it ships, and what it should be found for. */
|
|
72
72
|
export const specFileSchema = z
|
|
73
73
|
.object({
|
|
@@ -234,6 +234,8 @@ export const specFileSchema = z
|
|
|
234
234
|
.default({}),
|
|
235
235
|
/** A release or experiment check this many days late or more (critical: 7 days). */
|
|
236
236
|
"late-check": z.object({ days: z.number().int().min(1).default(2) }).strict().default({}),
|
|
237
|
+
/** A social account under social.accounts stopped working (needs reconnecting, turned off) or is not connected: read from the last social pull, if it is under `days` old. */
|
|
238
|
+
"social-account": z.object({ days: z.number().int().min(1).default(7) }).strict().default({}),
|
|
237
239
|
})
|
|
238
240
|
.strict()
|
|
239
241
|
.default({}),
|
package/dist/setup.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export interface DoctorCheck {
|
|
|
35
35
|
detail: string;
|
|
36
36
|
/** How to fix it, when it is not ok. */
|
|
37
37
|
fix?: string;
|
|
38
|
+
/** A warning about something that stopped working, not an optional step to set up. */
|
|
39
|
+
attention?: boolean;
|
|
38
40
|
}
|
|
39
41
|
/** Where each store CLI keeps its saved accounts (`appstore accounts add`, `gps accounts add`). */
|
|
40
42
|
export declare function savedAccountsFile(store: StoreId, env?: NodeJS.ProcessEnv): string;
|
|
@@ -47,6 +49,12 @@ export declare function savedAccounts(store: StoreId, env?: NodeJS.ProcessEnv):
|
|
|
47
49
|
* can take a minute through npx; `pull` shows their errors.
|
|
48
50
|
*/
|
|
49
51
|
export declare function probeConnections(project: Project, checks: DoctorCheck[], env?: NodeJS.ProcessEnv, fetcher?: typeof fetch, timeoutMs?: number): Promise<DoctorCheck[]>;
|
|
52
|
+
/**
|
|
53
|
+
* The social accounts this repo uses (social.accounts, or any when it is not set), asked live:
|
|
54
|
+
* one that needs reconnecting is a warning with the command that fixes it. Only when
|
|
55
|
+
* APPEEKY_API_KEY is set and the repo uses social (social.accounts or a social pull).
|
|
56
|
+
*/
|
|
57
|
+
export declare function probeSocial(project: Project, checks: DoctorCheck[], env?: NodeJS.ProcessEnv, fetcher?: typeof fetch, timeoutMs?: number): Promise<DoctorCheck[]>;
|
|
50
58
|
/** What is set up for this repo, and what is missing. Works without a spec (it says so). */
|
|
51
59
|
export declare function diagnose(root: string, project: Project | null, env?: NodeJS.ProcessEnv, nodeVersion?: string): DoctorCheck[];
|
|
52
60
|
export {};
|
package/dist/setup.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { installedTargets } from "./agents.js";
|
|
4
|
+
import { AppeekyApi } from "./appeeky-api.js";
|
|
4
5
|
import { SPEC_DIR, SPEC_FILE } from "./files.js";
|
|
6
|
+
import { accountLabel, accountMatches, accountProblems, listAccountRows, reconnectCommand, toAccount } from "./social.js";
|
|
5
7
|
import { words } from "./text.js";
|
|
6
8
|
import { createTransport, hasLocalKeys, npxPackage, onPath, STORE_CLIS } from "./transport.js";
|
|
7
9
|
/** App Store apps matching a name, from Apple's public search. */
|
|
@@ -271,6 +273,42 @@ export async function probeConnections(project, checks, env = process.env, fetch
|
|
|
271
273
|
}
|
|
272
274
|
return out;
|
|
273
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* The social accounts this repo uses (social.accounts, or any when it is not set), asked live:
|
|
278
|
+
* one that needs reconnecting is a warning with the command that fixes it. Only when
|
|
279
|
+
* APPEEKY_API_KEY is set and the repo uses social (social.accounts or a social pull).
|
|
280
|
+
*/
|
|
281
|
+
export async function probeSocial(project, checks, env = process.env, fetcher, timeoutMs = 15_000) {
|
|
282
|
+
const key = env.APPEEKY_API_KEY;
|
|
283
|
+
const only = project.spec.social?.accounts;
|
|
284
|
+
if (!key || !(only?.length || existsSync(join(project.root, SPEC_DIR, "social", "accounts.yaml"))))
|
|
285
|
+
return checks;
|
|
286
|
+
const api = new AppeekyApi(key, { baseUrl: env.APPEEKY_API_URL, fetcher });
|
|
287
|
+
let timer;
|
|
288
|
+
try {
|
|
289
|
+
const timeout = new Promise((_, reject) => {
|
|
290
|
+
timer = setTimeout(() => reject(new Error(`no answer in ${timeoutMs / 1000}s`)), timeoutMs);
|
|
291
|
+
});
|
|
292
|
+
const all = (await Promise.race([listAccountRows(api), timeout])).map(toAccount);
|
|
293
|
+
const accounts = only?.length ? all.filter((a) => accountMatches(a, only)) : all;
|
|
294
|
+
const working = accounts.filter((a) => a.active);
|
|
295
|
+
const out = [];
|
|
296
|
+
if (working.length)
|
|
297
|
+
out.push(ok("social", `connected: ${working.map((a) => `${a.platform} ${accountLabel(a)}`).join(", ")}`));
|
|
298
|
+
for (const p of accountProblems(accounts, only))
|
|
299
|
+
out.push({ ...warn("social", p.message, p.fix), attention: true });
|
|
300
|
+
if (!out.length)
|
|
301
|
+
out.push({ ...warn("social", "No social account connected in Appeeky", `Run \`${reconnectCommand("<platform>")}\` (tiktok, instagram, …) and sign in with the link.`), attention: true });
|
|
302
|
+
return [...checks, ...out];
|
|
303
|
+
}
|
|
304
|
+
catch (e) {
|
|
305
|
+
return [...checks, { ...warn("social", `Could not read the social accounts: ${e.message}`, "Check APPEEKY_API_KEY, or run `appeeky-spec social pull` to see the error."), attention: true }];
|
|
306
|
+
}
|
|
307
|
+
finally {
|
|
308
|
+
if (timer)
|
|
309
|
+
clearTimeout(timer);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
274
312
|
/** What is set up for this repo, and what is missing. Works without a spec (it says so). */
|
|
275
313
|
export function diagnose(root, project, env = process.env, nodeVersion = process.versions.node) {
|
|
276
314
|
const out = [];
|
package/dist/social.d.ts
CHANGED
|
@@ -21,6 +21,10 @@ export interface SocialAccount {
|
|
|
21
21
|
platform: string;
|
|
22
22
|
name: string;
|
|
23
23
|
active: boolean;
|
|
24
|
+
/** Why it cannot post or be read: "needs reconnecting" or "turned off". Absent when it works. */
|
|
25
|
+
problem?: string;
|
|
26
|
+
/** The last error the platform gave for it, as Appeeky recorded it. */
|
|
27
|
+
lastError?: string;
|
|
24
28
|
}
|
|
25
29
|
export interface SocialPlatformResult {
|
|
26
30
|
platform: string;
|
|
@@ -97,13 +101,15 @@ export interface SocialPost {
|
|
|
97
101
|
}
|
|
98
102
|
export declare const socialDir: (root: string) => string;
|
|
99
103
|
export declare const draftsDir: (root: string) => string;
|
|
100
|
-
interface AccountRow {
|
|
104
|
+
export interface AccountRow {
|
|
101
105
|
id: string;
|
|
102
106
|
platform: string;
|
|
103
107
|
displayName?: string | null;
|
|
104
108
|
platformUserId?: string | null;
|
|
105
109
|
isActive?: boolean | null;
|
|
106
110
|
needsReconnect?: boolean | null;
|
|
111
|
+
lastError?: string | null;
|
|
112
|
+
updatedAt?: string | null;
|
|
107
113
|
}
|
|
108
114
|
interface PostRow {
|
|
109
115
|
id: string;
|
|
@@ -191,7 +197,56 @@ export declare function fetchSocial(api: AppeekyApi, options?: {
|
|
|
191
197
|
}): Promise<SocialData>;
|
|
192
198
|
export declare function summaryMarkdown(accounts: SocialAccount[], posts: SocialPost[], now?: Date, more?: Pick<SocialData, "nativePosts" | "comments" | "insights">): string;
|
|
193
199
|
export declare function saveSocial(root: string, data: SocialData, now?: Date): Promise<void>;
|
|
200
|
+
/** accounts.yaml with the time of the social pull that wrote it (absent in files from before 0.10). */
|
|
201
|
+
export declare function readAccountsFile(root: string): Promise<{
|
|
202
|
+
accounts: SocialAccount[];
|
|
203
|
+
checkedAt?: string;
|
|
204
|
+
}>;
|
|
194
205
|
export declare function readAccounts(root: string): Promise<SocialAccount[]>;
|
|
206
|
+
/**
|
|
207
|
+
* The platforms keep a connection only so long: a revoked permission, a changed password or a
|
|
208
|
+
* token the platform will not refresh, and Appeeky marks the account `needsReconnect`. Nothing
|
|
209
|
+
* posts or reads on it until someone signs in again, so Spec says so wherever it looks (social
|
|
210
|
+
* pull, doctor, the daily alerts) and `social connect` gives the sign-in link, without the dashboard.
|
|
211
|
+
*/
|
|
212
|
+
export declare const reconnectCommand: (platform: string) => string;
|
|
213
|
+
export interface AccountProblem {
|
|
214
|
+
platform: string;
|
|
215
|
+
/** The connected account with the problem; absent for a social.accounts entry that matches none. */
|
|
216
|
+
account?: SocialAccount;
|
|
217
|
+
/** The social.accounts entry that matches no connected account. */
|
|
218
|
+
ref?: string;
|
|
219
|
+
message: string;
|
|
220
|
+
fix: string;
|
|
221
|
+
}
|
|
222
|
+
/** Accounts that cannot post or be read, and entries under social.accounts that no connected account matches. */
|
|
223
|
+
export declare function accountProblems(accounts: SocialAccount[], only?: string[]): AccountProblem[];
|
|
224
|
+
export declare const listAccountRows: (api: AppeekyApi) => Promise<AccountRow[]>;
|
|
225
|
+
/** The Appeeky API route that starts a sign-in for a platform: GET, `account_id` to reconnect one account. */
|
|
226
|
+
export declare const connectPath: (platform: string) => string;
|
|
227
|
+
export interface ConnectLink {
|
|
228
|
+
/** Sign in here (in a browser). */
|
|
229
|
+
url: string;
|
|
230
|
+
/** The same sign-in, made to open on a phone (where the TikTok or Instagram app is signed in). */
|
|
231
|
+
phoneUrl?: string;
|
|
232
|
+
expiresAt?: string;
|
|
233
|
+
}
|
|
234
|
+
export declare class ConnectUnavailableError extends Error {
|
|
235
|
+
constructor(platform: string);
|
|
236
|
+
}
|
|
237
|
+
/** A sign-in link for a platform, from the Appeeky API (which keeps the platform tokens and refreshes them). */
|
|
238
|
+
export declare function connectLink(api: AppeekyApi, platform: string, accountId?: string): Promise<ConnectLink>;
|
|
239
|
+
/**
|
|
240
|
+
* Waits until the sign-in lands: an account on the platform that works and is new, was broken
|
|
241
|
+
* before, or changed since (a fresh sign-in on an account that already worked). Null on timeout.
|
|
242
|
+
*/
|
|
243
|
+
export declare function waitForConnection(api: AppeekyApi, platform: string, before: AccountRow[], options?: {
|
|
244
|
+
timeoutMs?: number;
|
|
245
|
+
intervalMs?: number;
|
|
246
|
+
accountId?: string;
|
|
247
|
+
sleep?: (ms: number) => Promise<void>;
|
|
248
|
+
now?: () => number;
|
|
249
|
+
}): Promise<SocialAccount | null>;
|
|
195
250
|
/** TikTok's posting options, in the words a draft uses; each maps to a key of `extra.tiktok` in the API. */
|
|
196
251
|
export declare const PRIVACY: {
|
|
197
252
|
readonly public: "PUBLIC_TO_EVERYONE";
|
package/dist/social.js
CHANGED
|
@@ -25,7 +25,15 @@ export const socialDir = (root) => join(root, SPEC_DIR, "social");
|
|
|
25
25
|
export const draftsDir = (root) => join(socialDir(root), "drafts");
|
|
26
26
|
const compact = (o) => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined && v !== null && v !== ""));
|
|
27
27
|
export function toAccount(r) {
|
|
28
|
-
|
|
28
|
+
const problem = r.needsReconnect ? "needs reconnecting" : r.isActive === false ? "turned off" : undefined;
|
|
29
|
+
return {
|
|
30
|
+
id: r.id,
|
|
31
|
+
platform: r.platform,
|
|
32
|
+
name: r.displayName || r.platformUserId || r.platform,
|
|
33
|
+
active: !problem,
|
|
34
|
+
...(problem ? { problem } : {}),
|
|
35
|
+
...(r.lastError?.trim() ? { lastError: r.lastError.trim() } : {}),
|
|
36
|
+
};
|
|
29
37
|
}
|
|
30
38
|
export function toPost(r, analytics = []) {
|
|
31
39
|
return compact({
|
|
@@ -242,7 +250,7 @@ const jsonl = (rows) => rows.map((r) => JSON.stringify(r)).join("\n") + (rows.le
|
|
|
242
250
|
export async function saveSocial(root, data, now = new Date()) {
|
|
243
251
|
const dir = socialDir(root);
|
|
244
252
|
await mkdir(dir, { recursive: true });
|
|
245
|
-
await writeFile(join(dir, "accounts.yaml"), YAML.stringify({ accounts: data.accounts }, { lineWidth: 0 }));
|
|
253
|
+
await writeFile(join(dir, "accounts.yaml"), YAML.stringify({ checkedAt: now.toISOString(), accounts: data.accounts }, { lineWidth: 0 }));
|
|
246
254
|
await writeFile(join(dir, "posts.jsonl"), jsonl(data.posts));
|
|
247
255
|
if (data.nativePosts)
|
|
248
256
|
await writeFile(join(dir, "native-posts.jsonl"), jsonl(data.nativePosts));
|
|
@@ -260,12 +268,106 @@ export async function saveSocial(root, data, now = new Date()) {
|
|
|
260
268
|
const more = { nativePosts: await kept("native-posts.jsonl", data.nativePosts), comments: await kept("comments.jsonl", data.comments), insights };
|
|
261
269
|
await writeFile(join(dir, "summary.md"), summaryMarkdown(data.accounts, data.posts, now, more));
|
|
262
270
|
}
|
|
271
|
+
/** accounts.yaml with the time of the social pull that wrote it (absent in files from before 0.10). */
|
|
272
|
+
export async function readAccountsFile(root) {
|
|
273
|
+
const file = join(socialDir(root), "accounts.yaml");
|
|
274
|
+
if (!existsSync(file))
|
|
275
|
+
return { accounts: [] };
|
|
276
|
+
const parsed = YAML.parse(await readFile(file, "utf8"));
|
|
277
|
+
return { accounts: parsed?.accounts ?? [], ...(parsed?.checkedAt ? { checkedAt: parsed.checkedAt } : {}) };
|
|
278
|
+
}
|
|
263
279
|
export async function readAccounts(root) {
|
|
264
280
|
const file = join(socialDir(root), "accounts.yaml");
|
|
265
281
|
if (!existsSync(file))
|
|
266
282
|
return [];
|
|
267
283
|
return (YAML.parse(await readFile(file, "utf8"))?.accounts ?? []);
|
|
268
284
|
}
|
|
285
|
+
// ── Account health ──────────────────────────────────────────────────────────
|
|
286
|
+
/**
|
|
287
|
+
* The platforms keep a connection only so long: a revoked permission, a changed password or a
|
|
288
|
+
* token the platform will not refresh, and Appeeky marks the account `needsReconnect`. Nothing
|
|
289
|
+
* posts or reads on it until someone signs in again, so Spec says so wherever it looks (social
|
|
290
|
+
* pull, doctor, the daily alerts) and `social connect` gives the sign-in link, without the dashboard.
|
|
291
|
+
*/
|
|
292
|
+
export const reconnectCommand = (platform) => `appeeky-spec social connect ${platformKey(platform)}`;
|
|
293
|
+
/** Accounts that cannot post or be read, and entries under social.accounts that no connected account matches. */
|
|
294
|
+
export function accountProblems(accounts, only = []) {
|
|
295
|
+
const out = [];
|
|
296
|
+
for (const a of accounts) {
|
|
297
|
+
if (a.active)
|
|
298
|
+
continue;
|
|
299
|
+
out.push({
|
|
300
|
+
platform: platformKey(a.platform),
|
|
301
|
+
account: a,
|
|
302
|
+
message: `${a.platform} ${accountLabel(a)} ${a.problem ?? "stopped working"}${a.lastError ? ` (${a.lastError})` : ""}`,
|
|
303
|
+
fix: `Run \`${reconnectCommand(a.platform)}\` and sign in with the link it gives, or reconnect it at appeeky.com/dashboard.`,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
for (const ref of only) {
|
|
307
|
+
if (accounts.some((a) => accountMatches(a, [ref])))
|
|
308
|
+
continue;
|
|
309
|
+
const platform = platformKey(/^([a-z]+):/i.exec(ref.trim())?.[1] ?? ref.trim());
|
|
310
|
+
out.push({
|
|
311
|
+
platform,
|
|
312
|
+
ref,
|
|
313
|
+
message: `${ref} is under social.accounts but not connected in Appeeky`,
|
|
314
|
+
fix: `Run \`${reconnectCommand(platform)}\`, connect it at appeeky.com/dashboard, or take it out of social.accounts.`,
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
return out;
|
|
318
|
+
}
|
|
319
|
+
export const listAccountRows = async (api) => (await api.get("/connect/social/accounts")) ?? [];
|
|
320
|
+
/** The Appeeky API route that starts a sign-in for a platform: GET, `account_id` to reconnect one account. */
|
|
321
|
+
export const connectPath = (platform) => `/connect/social/accounts/connect/${encodeURIComponent(platformKey(platform))}`;
|
|
322
|
+
export class ConnectUnavailableError extends Error {
|
|
323
|
+
constructor(platform) {
|
|
324
|
+
super(`The Appeeky API does not hand out sign-in links yet (${connectPath(platform)} is not there). Reconnect ${platform} at appeeky.com/dashboard for now; \`social connect\` works as soon as the API has the route.`);
|
|
325
|
+
this.name = "ConnectUnavailableError";
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
/** A sign-in link for a platform, from the Appeeky API (which keeps the platform tokens and refreshes them). */
|
|
329
|
+
export async function connectLink(api, platform, accountId) {
|
|
330
|
+
let data;
|
|
331
|
+
try {
|
|
332
|
+
data = await api.get(connectPath(platform), accountId ? { account_id: accountId } : {});
|
|
333
|
+
}
|
|
334
|
+
catch (e) {
|
|
335
|
+
if (e instanceof AppeekyApiError && e.status === 404)
|
|
336
|
+
throw new ConnectUnavailableError(platform);
|
|
337
|
+
throw e;
|
|
338
|
+
}
|
|
339
|
+
const url = data?.authUrl ?? data?.url;
|
|
340
|
+
if (!url)
|
|
341
|
+
throw new Error(`The Appeeky API gave no sign-in link for ${platform}.`);
|
|
342
|
+
return { url, ...(data?.handoff?.url ? { phoneUrl: data.handoff.url } : {}), ...((data?.handoff?.expiresAt ?? data?.expiresAt) ? { expiresAt: data?.handoff?.expiresAt ?? data?.expiresAt } : {}) };
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Waits until the sign-in lands: an account on the platform that works and is new, was broken
|
|
346
|
+
* before, or changed since (a fresh sign-in on an account that already worked). Null on timeout.
|
|
347
|
+
*/
|
|
348
|
+
export async function waitForConnection(api, platform, before, options = {}) {
|
|
349
|
+
const { timeoutMs = 600_000, intervalMs = 5_000 } = options;
|
|
350
|
+
const sleep = options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
351
|
+
const now = options.now ?? Date.now;
|
|
352
|
+
const key = platformKey(platform);
|
|
353
|
+
const end = now() + timeoutMs;
|
|
354
|
+
for (;;) {
|
|
355
|
+
const rows = await listAccountRows(api).catch(() => null);
|
|
356
|
+
for (const row of rows ?? []) {
|
|
357
|
+
if (platformKey(row.platform) !== key || (options.accountId && row.id !== options.accountId))
|
|
358
|
+
continue;
|
|
359
|
+
const account = toAccount(row);
|
|
360
|
+
if (!account.active)
|
|
361
|
+
continue;
|
|
362
|
+
const prev = before.find((b) => b.id === row.id);
|
|
363
|
+
if (!prev || !toAccount(prev).active || prev.updatedAt !== row.updatedAt)
|
|
364
|
+
return account;
|
|
365
|
+
}
|
|
366
|
+
if (now() >= end)
|
|
367
|
+
return null;
|
|
368
|
+
await sleep(intervalMs);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
269
371
|
// ── Drafts ──────────────────────────────────────────────────────────────────
|
|
270
372
|
/** TikTok's posting options, in the words a draft uses; each maps to a key of `extra.tiktok` in the API. */
|
|
271
373
|
export const PRIVACY = { public: "PUBLIC_TO_EVERYONE", friends: "MUTUAL_FOLLOW_FRIENDS", followers: "FOLLOWER_OF_CREATOR", only_me: "SELF_ONLY" };
|
|
@@ -507,8 +609,19 @@ function tiktokIssues(draft, toTikTok) {
|
|
|
507
609
|
export function draftIssues(draft, accounts, now = new Date()) {
|
|
508
610
|
const issues = [];
|
|
509
611
|
const { accounts: to, missing, ambiguous } = resolveAccounts(draft, accounts);
|
|
510
|
-
|
|
511
|
-
|
|
612
|
+
// A ref that only matches accounts that stopped working: say how to bring them back.
|
|
613
|
+
const everyone = accounts.map((a) => ({ ...a, active: true }));
|
|
614
|
+
const unknown = [];
|
|
615
|
+
for (const ref of missing) {
|
|
616
|
+
const broken = resolveAccounts({ accounts: [ref] }, everyone).accounts.filter((a) => !accounts.find((x) => x.id === a.id)?.active);
|
|
617
|
+
if (broken.length)
|
|
618
|
+
for (const a of broken)
|
|
619
|
+
issues.push(`${a.platform} ${accountLabel(a)} ${a.problem ?? "stopped working"}: run \`${reconnectCommand(a.platform)}\``);
|
|
620
|
+
else
|
|
621
|
+
unknown.push(ref);
|
|
622
|
+
}
|
|
623
|
+
if (unknown.length)
|
|
624
|
+
issues.push(`no connected account for ${unknown.join(", ")}`);
|
|
512
625
|
for (const a of ambiguous) {
|
|
513
626
|
issues.push(a.platform
|
|
514
627
|
? `${a.ref} matches ${a.choices.length} ${a.platform} accounts (${a.choices.join(", ")}): name the ones to post on, e.g. ${a.platform}:${a.choices[0]}, or write ${a.platform}:all to post on all ${a.choices.length}`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appeeky/spec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Your app's store listing as a spec: lint it, check keyword coverage, diff it against the live store and push it to App Store Connect and Google Play.",
|
|
5
5
|
"license": "FSL-1.1-MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -52,11 +52,11 @@ The push workflow reads `APPEEKY_API_KEY`, or your own store keys from secrets o
|
|
|
52
52
|
|
|
53
53
|
## 3. Alerts
|
|
54
54
|
|
|
55
|
-
`alerts` turns the files the daily run wrote into what needs a person: `rank-drop` (from the ranks in `appeeky/releases/`), `release-lost`, `category-drop`, `low-ratings`, `competitor-change` (on targets only), `visibility-drop`, `search-drop` (`appeeky/seo/daily.csv`)
|
|
55
|
+
`alerts` turns the files the daily run wrote into what needs a person: `rank-drop` (from the ranks in `appeeky/releases/`), `release-lost`, `category-drop`, `low-ratings`, `competitor-change` (on targets only), `visibility-drop`, `search-drop` (`appeeky/seo/daily.csv`), `late-check` and `social-account` (`appeeky/social/accounts.yaml`: an account that needs reconnecting, critical, or a `social.accounts` entry not connected). Each has `severity` (`warn`/`critical`), `numbers`, `window`, `source` and `next`. It makes no network call except the delivery flags.
|
|
56
56
|
|
|
57
57
|
- Read them: `alerts --json` (`--new` for the ones not reported yet). `--markdown -o <file>` writes an issue body; the file is empty when nothing is open.
|
|
58
58
|
- Dedupe: `--record` writes `appeeky/alerts.json`; the daily run commits it, so an alert is new once, again when it turns critical, and again only after it cleared and came back. Never hand-edit it; delete it to report everything again.
|
|
59
|
-
- Thresholds: `alerts:` in `appeeky.spec.yaml` (`rank-drop.places`, `category-drop.places`/`days`, `low-ratings.days`/`min`/`ratio`, `search-drop.days`/`drop`/`min`, `competitor-change.days`, `visibility-drop.days`, `release-lost.days`, `late-check.days`), `off: [<kind>]` to turn kinds off. Too noisy: raise a threshold or turn the kind off in a pull request, not by deleting the state file.
|
|
59
|
+
- Thresholds: `alerts:` in `appeeky.spec.yaml` (`rank-drop.places`, `category-drop.places`/`days`, `low-ratings.days`/`min`/`ratio`, `search-drop.days`/`drop`/`min`, `competitor-change.days`, `visibility-drop.days`, `release-lost.days`, `late-check.days`, `social-account.days`), `off: [<kind>]` to turn kinds off. Too noisy: raise a threshold or turn the kind off in a pull request, not by deleting the state file.
|
|
60
60
|
- GitHub: `listing-daily.yml` runs `alerts --new -o .appeeky/alerts-new.md` and `alerts --record -o .appeeky/alerts.md`, then with `gh` keeps one open issue labelled `appeeky-spec-alert` (body: every open alert; a comment with the new ones; closed when the file is empty). A `listing-daily.yml` from an older version has neither the steps nor `issues: write`: delete it and run `init --ci` again (doctor's `alerts` line says so).
|
|
61
61
|
- Docker `daily`: `alerts --record`, plus `--webhook` when `ALERT_WEBHOOK_URL` is set (Slack-compatible `{"text"}`, new alerts only) and `--issue` when `GITHUB_TOKEN` is set (same issue through the GitHub API; needs Issues: Read and write; `ALERT_ISSUE=0` skips it). A failed post is not recorded and is retried the next day. `! GitHub answered 403 … Issues: Read and write` in the log: add that permission to the token or set `ALERT_ISSUE=0`.
|
|
62
62
|
- Other CI or cron: `alerts --record --webhook` (and `--issue` with `GITHUB_TOKEN`) after the daily commands, then commit `appeeky/alerts.json`.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: appeeky-spec-server
|
|
3
3
|
description: Set up and operate Appeeky Spec on a machine or container host the user owns, end to end over SSH, with the published ghcr.io/appeeky/appeeky-spec image. Covers choosing a host (a VM with Docker on Hetzner, DigitalOcean, AWS, Google Cloud or an office machine, or a platform scheduler such as Railway cron, Fly, Render or Cloud Run Jobs), installing Docker, docker-compose.yml and a chmod 600 .env, the first dry run, reading the logs, the healthcheck ping, updating the image, several apps on one host, moving hosts and fixing a failed routine. Use when asked to "run Spec on my server", "set it up on a VPS / Hetzner / EC2", "deploy the Docker image", "docker compose for Appeeky Spec", "it stopped pushing on the server", "update the container", or "move it to another server". For GitHub Actions and workflow files use appeeky-spec-automation; for the weekly review content use appeeky-spec-cofounder.
|
|
4
4
|
metadata:
|
|
5
|
-
version: 1.
|
|
5
|
+
version: 1.2.0
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Run Appeeky Spec on your own server
|
|
@@ -116,6 +116,7 @@ supercronic adds its own lines around each job. `Dry run: started following main
|
|
|
116
116
|
- **Reboots:** `restart: unless-stopped` plus Docker enabled at boot brings it back. A container stopped with `docker compose stop` stays stopped; `docker compose up -d` again.
|
|
117
117
|
- **Analytics CSVs:** `data pull` runs in `weekly`. `.appeeky/data/` is gitignored and every run starts from a fresh clone, so on a server they do not pile up: each weekly run reads the last 90 days. To keep a growing history, set `data: { commit: true }` in the spec (it commits revenue and other business data to the repo).
|
|
118
118
|
- **Status:** `docker compose ps`, `docker compose logs --since 24h`. Logs rotate at 3 × 10 MB.
|
|
119
|
+
- **A social account stopped working** (the `social-account` alert, or a `social` warning in the preflight): the person signs in again. `docker compose exec spec appeeky-spec social connect tiktok` prints the sign-in link (and one for the phone) and waits until the account works; give them the link, the sign-in is theirs. Until the Appeeky API hands out links, it says so and they reconnect at appeeky.com/dashboard.
|
|
119
120
|
- **Several apps:** one service and one env file each (`chmod 600` every one). Never point two services or two hosts at the same repo.
|
|
120
121
|
|
|
121
122
|
```yaml
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
name: appeeky-spec-social
|
|
3
3
|
description: Draft, check and measure organic social posts, and handle comments, in an Appeeky Spec repo (appeeky/social/). Use when asked what to post this week, to announce a release or feature on X, Instagram, TikTok, LinkedIn, Pinterest, Reddit, YouTube, Threads, Facebook or Bluesky, to write or fix a post draft, why `social check` fails, how past posts did, which hooks work, to schedule posts, or to answer, hide, like or delete comments. Posts go out only after a person merges them. For making a creator video see appeeky-spec-ugc; for the store listing see appeeky-spec.
|
|
4
4
|
metadata:
|
|
5
|
-
version: 1.
|
|
5
|
+
version: 1.1.0
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Organic social with Appeeky Spec
|
|
9
9
|
|
|
10
|
-
Posts are files. You draft them in `appeeky/social/drafts/`, a person reviews them in a pull request, and they go out after the merge through the accounts connected in Appeeky. Needs `APPEEKY_API_KEY` and the Startup plan or above in Appeeky; accounts are connected in Appeeky, not in the repo.
|
|
10
|
+
Posts are files. You draft them in `appeeky/social/drafts/`, a person reviews them in a pull request, and they go out after the merge through the accounts connected in Appeeky. Needs `APPEEKY_API_KEY` and the Startup plan or above in Appeeky; accounts are connected in Appeeky (which keeps their tokens and refreshes them), not in the repo; `social connect <platform>` gives the sign-in link to connect or reconnect one without the dashboard.
|
|
11
11
|
|
|
12
12
|
Run commands as `npx @appeeky/spec <command> --json`.
|
|
13
13
|
|
|
@@ -17,17 +17,25 @@ Run commands as `npx @appeeky/spec <command> --json`.
|
|
|
17
17
|
|
|
18
18
|
| File | Holds |
|
|
19
19
|
| --- | --- |
|
|
20
|
-
| `accounts.yaml` | connected accounts: `id`, `platform`, `name`, `active`. Draft only for
|
|
20
|
+
| `accounts.yaml` | `checkedAt` and the connected accounts: `id`, `platform`, `name`, `active`, and for one that does not work `problem` (`needs reconnecting`, `turned off`) and `lastError`. Draft only for active ones |
|
|
21
21
|
| `posts.jsonl` | posts made through Appeeky: `status`, `text`, `scheduledFor`, per platform `url`, `publishedAt`, `error`, `draft` (in the TikTok inbox) and `metrics` (views, impressions, reach, likes, comments, shares, reposts, saves, clicks) |
|
|
22
22
|
| `native-posts.jsonl` | posts made in each platform's own app, same metrics. Often most of an account's history |
|
|
23
23
|
| `comments.jsonl` | recent comments (`own: true` is the account itself, `repliedAt` means answered) |
|
|
24
24
|
| `insights.yaml` | followers and growth per account |
|
|
25
25
|
| `summary.md` | last 30 days per platform and account, the posts that did best, what sits in the TikTok inbox, what is waiting to go out |
|
|
26
26
|
|
|
27
|
-
The JSON output has counts and `
|
|
27
|
+
The JSON output has counts, `warnings` and `problems` (accounts that stopped working, and `social.accounts` entries no connected account matches, each with its `fix`). A file the API could not fill this time is kept from the last pull. If `appeeky/social/` is missing, the key or the connected accounts are missing: say so, do not guess handles.
|
|
28
28
|
|
|
29
29
|
Also read before drafting: existing drafts (do not repeat one), `whatsNew` in `appeeky/store/**`, `status --json` and `log --json` (what shipped and won), `appeeky/reviews/summary.md` (what users love, in their words), `.appeeky/data/README.md` and the attribution files it lists (which channels and smart links bring installs that pay), and UGC experiments in `appeeky/experiments/` so posts and creator videos do not repeat each other.
|
|
30
30
|
|
|
31
|
+
### Accounts that stop working
|
|
32
|
+
|
|
33
|
+
A platform drops the connection when someone revokes the permission, changes the password, or the token can no longer be refreshed; Appeeky then marks the account `needsReconnect`. Nothing posts or reads on it until a person signs in again. Spec reports it everywhere it looks: `social pull` (a `fix` line), `doctor` (a `social` warning to look at, also in the server's preflight), the daily `alerts` (`social-account`, critical) and `social check` (`… needs reconnecting: run \`appeeky-spec social connect <platform>\``).
|
|
34
|
+
|
|
35
|
+
`social connect <platform>` asks the Appeeky API for a sign-in link (and one for the phone, where the TikTok or Instagram app is signed in), prints it and waits until the account works (`--no-wait` to only print it, `--timeout <seconds>`, `--account @handle` when the platform has several). With one broken account on the platform it reconnects that one. It needs no spec, so on a Docker host: `docker compose exec spec appeeky-spec social connect tiktok`. The sign-in is the person's to do: give them the link, never sign in for them. If the API answers that it does not hand out links yet, the person reconnects at appeeky.com/dashboard.
|
|
36
|
+
|
|
37
|
+
`social.accounts` in `appeeky.spec.yaml` (`["instagram:@app", "tiktok:@app"]`) limits pull, doctor and the alerts to this app's accounts when the Appeeky account has others connected.
|
|
38
|
+
|
|
31
39
|
## 2. Decide what to post
|
|
32
40
|
|
|
33
41
|
- One reason per post: a new version or feature, a result worth saying plainly (a rank won, a rating that rose), something users praise that posts never mention, a question commenters keep asking.
|
|
@@ -82,7 +90,7 @@ Put a smart link in the text when `attribution:` is set up, one per post or chan
|
|
|
82
90
|
|
|
83
91
|
`social check --json` checks every draft still marked `draft` against `accounts.yaml` and exits 1 on any issue (`{ drafts: [{ file, issues }] }`). Fix and run again until `issues` is empty everywhere. The reasons it refuses:
|
|
84
92
|
|
|
85
|
-
- `no connected account for …`; `… matches N … accounts (…): name the ones to post on … or write <platform>:all`
|
|
93
|
+
- `<platform> <handle> needs reconnecting: run \`appeeky-spec social connect <platform>\`` (tell the person, do not draft around it); `no connected account for …`; `… matches N … accounts (…): name the ones to post on … or write <platform>:all`
|
|
86
94
|
- `<platform>: <n>/<limit> characters`
|
|
87
95
|
- `<platform> needs an image or video (media:)`, `youtube needs a video`, `youtube: needs exactly one video (media:), and no images`
|
|
88
96
|
- `a post is either images or one video, not both`, `<n> images, at most <m>`, `<n> videos, at most <m>`
|
|
@@ -116,6 +124,7 @@ After the next `social pull` (daily in `listing-daily.yml`), find the sent post
|
|
|
116
124
|
|
|
117
125
|
## Mistakes to avoid
|
|
118
126
|
|
|
127
|
+
- Treating a `needs reconnecting` account as gone, or moving its post to another platform without asking: give the person the `social connect` link.
|
|
119
128
|
- Drafting for a handle that is not in `accounts.yaml`, or a bare platform name when it has several accounts.
|
|
120
129
|
- One text pasted to every platform: an X post over 280, a Reddit post with no subreddit, Instagram/TikTok/YouTube without media.
|
|
121
130
|
- Promoting the app on TikTok without `disclosure: own_brand`, or posting an AI clip without `inbox_draft: true` / `synthetic_media: true`.
|