Review replies: storebound reviews list | draft | send, review-replies skill
App Store customerReviews / customerReviewResponses and Google Play reviews.list / reviews.reply. draft writes one Markdown file per unanswered review to .storebound/replies (front matter approved: false, never overwritten); send only sends approved, unsent drafts that pass the checks (Play 350 characters, no incentives or rating requests, personal data / link / tone warnings) after a confirmation, and marks them sent. MCP: reviews_list, reviews_draft; send is never exposed.
This commit is contained in:
parent
56e107dbbe
commit
c99febc45b
11 changed files with 508 additions and 1 deletions
|
|
@ -45,6 +45,7 @@ These rules apply to every AI tool that uses storebound (skills, MCP server or t
|
||||||
- `skills/privacy-policy/SKILL.md`: Write and host one studio-wide privacy policy page for all of a developer's mobile games
|
- `skills/privacy-policy/SKILL.md`: Write and host one studio-wide privacy policy page for all of a developer's mobile games
|
||||||
- `skills/release-management/SKILL.md`: Ship updates safely after the first release
|
- `skills/release-management/SKILL.md`: Ship updates safely after the first release
|
||||||
- `skills/review-rejections/SKILL.md`: Triage and answer an App Store or Google Play rejection, policy warning or strike for a mobile game
|
- `skills/review-rejections/SKILL.md`: Triage and answer an App Store or Google Play rejection, policy warning or strike for a mobile game
|
||||||
|
- `skills/review-replies/SKILL.md`: Reply to App Store and Google Play reviews of a mobile game the safe way
|
||||||
- `skills/store-declarations/SKILL.md`: Answer the store compliance forms for a mobile game
|
- `skills/store-declarations/SKILL.md`: Answer the store compliance forms for a mobile game
|
||||||
- `skills/store-health/SKILL.md`: Watch a released mobile game's crash and ANR health on both stores
|
- `skills/store-health/SKILL.md`: Watch a released mobile game's crash and ANR health on both stores
|
||||||
- `skills/store-iap-setup/SKILL.md`: Create and price in-app purchases (consumables, non-consumables like "remove ads", coin/gem packs, starter packs) on Google Play and App Store Connect from one product list
|
- `skills/store-iap-setup/SKILL.md`: Create and price in-app purchases (consumables, non-consumables like "remove ads", coin/gem packs, starter packs) on Google Play and App Store Connect from one product list
|
||||||
|
|
|
||||||
1
.github/copilot-instructions.md
vendored
1
.github/copilot-instructions.md
vendored
|
|
@ -47,6 +47,7 @@ These rules apply to every AI tool that uses storebound (skills, MCP server or t
|
||||||
| `privacy-policy` | Write and host one studio-wide privacy policy page for all of a developer's mobile games |
|
| `privacy-policy` | Write and host one studio-wide privacy policy page for all of a developer's mobile games |
|
||||||
| `release-management` | Ship updates safely after the first release |
|
| `release-management` | Ship updates safely after the first release |
|
||||||
| `review-rejections` | Triage and answer an App Store or Google Play rejection, policy warning or strike for a mobile game |
|
| `review-rejections` | Triage and answer an App Store or Google Play rejection, policy warning or strike for a mobile game |
|
||||||
|
| `review-replies` | Reply to App Store and Google Play reviews of a mobile game the safe way |
|
||||||
| `store-declarations` | Answer the store compliance forms for a mobile game |
|
| `store-declarations` | Answer the store compliance forms for a mobile game |
|
||||||
| `store-health` | Watch a released mobile game's crash and ANR health on both stores |
|
| `store-health` | Watch a released mobile game's crash and ANR health on both stores |
|
||||||
| `store-iap-setup` | Create and price in-app purchases (consumables, non-consumables like "remove ads", coin/gem packs, starter packs) on Google Play and App Store Connect from one product list |
|
| `store-iap-setup` | Create and price in-app purchases (consumables, non-consumables like "remove ads", coin/gem packs, starter packs) on Google Play and App Store Connect from one product list |
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ These rules apply to every AI tool that uses storebound (skills, MCP server or t
|
||||||
- `skills/privacy-policy/SKILL.md`: Write and host one studio-wide privacy policy page for all of a developer's mobile games
|
- `skills/privacy-policy/SKILL.md`: Write and host one studio-wide privacy policy page for all of a developer's mobile games
|
||||||
- `skills/release-management/SKILL.md`: Ship updates safely after the first release
|
- `skills/release-management/SKILL.md`: Ship updates safely after the first release
|
||||||
- `skills/review-rejections/SKILL.md`: Triage and answer an App Store or Google Play rejection, policy warning or strike for a mobile game
|
- `skills/review-rejections/SKILL.md`: Triage and answer an App Store or Google Play rejection, policy warning or strike for a mobile game
|
||||||
|
- `skills/review-replies/SKILL.md`: Reply to App Store and Google Play reviews of a mobile game the safe way
|
||||||
- `skills/store-declarations/SKILL.md`: Answer the store compliance forms for a mobile game
|
- `skills/store-declarations/SKILL.md`: Answer the store compliance forms for a mobile game
|
||||||
- `skills/store-health/SKILL.md`: Watch a released mobile game's crash and ANR health on both stores
|
- `skills/store-health/SKILL.md`: Watch a released mobile game's crash and ANR health on both stores
|
||||||
- `skills/store-iap-setup/SKILL.md`: Create and price in-app purchases (consumables, non-consumables like "remove ads", coin/gem packs, starter packs) on Google Play and App Store Connect from one product list
|
- `skills/store-iap-setup/SKILL.md`: Create and price in-app purchases (consumables, non-consumables like "remove ads", coin/gem packs, starter packs) on Google Play and App Store Connect from one product list
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ These rules apply to every AI tool that uses storebound (skills, MCP server or t
|
||||||
| `privacy-policy` | Write and host one studio-wide privacy policy page for all of a developer's mobile games |
|
| `privacy-policy` | Write and host one studio-wide privacy policy page for all of a developer's mobile games |
|
||||||
| `release-management` | Ship updates safely after the first release |
|
| `release-management` | Ship updates safely after the first release |
|
||||||
| `review-rejections` | Triage and answer an App Store or Google Play rejection, policy warning or strike for a mobile game |
|
| `review-rejections` | Triage and answer an App Store or Google Play rejection, policy warning or strike for a mobile game |
|
||||||
|
| `review-replies` | Reply to App Store and Google Play reviews of a mobile game the safe way |
|
||||||
| `store-declarations` | Answer the store compliance forms for a mobile game |
|
| `store-declarations` | Answer the store compliance forms for a mobile game |
|
||||||
| `store-health` | Watch a released mobile game's crash and ANR health on both stores |
|
| `store-health` | Watch a released mobile game's crash and ANR health on both stores |
|
||||||
| `store-iap-setup` | Create and price in-app purchases (consumables, non-consumables like "remove ads", coin/gem packs, starter packs) on Google Play and App Store Connect from one product list |
|
| `store-iap-setup` | Create and price in-app purchases (consumables, non-consumables like "remove ads", coin/gem packs, starter packs) on Google Play and App Store Connect from one product list |
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ const COMMANDS: Record<string, [() => Promise<Mod>, string]> = {
|
||||||
'check': [() => import('./check'), 'validate config, copy files, data safety answers and products (offline); --aso keyword audit'],
|
'check': [() => import('./check'), 'validate config, copy files, data safety answers and products (offline); --aso keyword audit'],
|
||||||
'validate': [() => import('./validate'), 'read-only store readiness report with ordered blockers (--apple / --play), plus local renders checks (--no-local skips); exit 1 on blockers'],
|
'validate': [() => import('./validate'), 'read-only store readiness report with ordered blockers (--apple / --play), plus local renders checks (--no-local skips); exit 1 on blockers'],
|
||||||
'health': [() => import('./health'), 'crash / ANR vitals (Play) and diagnostics (App Store), read-only; --weekly writes a markdown report; exit 1 over a threshold'],
|
'health': [() => import('./health'), 'crash / ANR vitals (Play) and diagnostics (App Store), read-only; --weekly writes a markdown report; exit 1 over a threshold'],
|
||||||
|
'reviews': [() => import('./reviews'), 'list | draft (local reply drafts in .storebound/replies) | send (approved drafts only, asks first)'],
|
||||||
'whats-new': [() => import('./whats-new'), 'draft player-facing release notes from git log into the listing files (--since <tag>)'],
|
'whats-new': [() => import('./whats-new'), 'draft player-facing release notes from git log into the listing files (--since <tag>)'],
|
||||||
'play products': [() => import('./play/products'), 'one-time products: create / update, regional prices, activate'],
|
'play products': [() => import('./play/products'), 'one-time products: create / update, regional prices, activate'],
|
||||||
'play listing': [() => import('./play/listing'), 'app details + title / short / full description per language'],
|
'play listing': [() => import('./play/listing'), 'app details + title / short / full description per language'],
|
||||||
|
|
|
||||||
34
cli/lib/frontmatter.ts
Normal file
34
cli/lib/frontmatter.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
// Minimal front matter for the local Markdown drafts storebound writes (review replies): "---", one `key: value` per
|
||||||
|
// line (strings, numbers, true / false, null; strings JSON-quoted when needed), "---", then the body. Pure.
|
||||||
|
|
||||||
|
export type FmValue = string | number | boolean | null;
|
||||||
|
|
||||||
|
export function parseFrontMatter(text: string): { data: Record<string, FmValue>; body: string } {
|
||||||
|
const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
|
||||||
|
if (!m) return { data: {}, body: text };
|
||||||
|
const data: Record<string, FmValue> = {};
|
||||||
|
for (const line of m[1]!.split(/\r?\n/)) {
|
||||||
|
const kv = /^([A-Za-z_][\w-]*):\s*(.*)$/.exec(line);
|
||||||
|
if (!kv) continue;
|
||||||
|
data[kv[1]!] = scalar(kv[2]!.trim());
|
||||||
|
}
|
||||||
|
return { data, body: text.slice(m[0].length) };
|
||||||
|
}
|
||||||
|
|
||||||
|
function scalar(v: string): FmValue {
|
||||||
|
if (v === 'true') return true;
|
||||||
|
if (v === 'false') return false;
|
||||||
|
if (v === 'null' || v === '~' || v === '') return null;
|
||||||
|
if (/^-?\d+(\.\d+)?$/.test(v)) return Number(v);
|
||||||
|
if (v.startsWith('"')) { try { return JSON.parse(v) as string; } catch { return v; } }
|
||||||
|
if (v.startsWith("'") && v.endsWith("'")) return v.slice(1, -1).replace(/''/g, "'");
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
const plain = (s: string) => /^[\w./@+-][\w ./@:+-]*$/.test(s) && !/^(true|false|null|~|-?\d+(\.\d+)?)$/.test(s) && !/ $/.test(s);
|
||||||
|
|
||||||
|
export function stringifyFrontMatter(data: Record<string, FmValue | undefined>, body: string): string {
|
||||||
|
const lines = Object.entries(data).filter(([, v]) => v !== undefined)
|
||||||
|
.map(([k, v]) => `${k}: ${v === null ? 'null' : typeof v === 'string' ? (plain(v) ? v : JSON.stringify(v)) : String(v)}`);
|
||||||
|
return `---\n${lines.join('\n')}\n---\n${body.startsWith('\n') ? body : '\n' + body}`;
|
||||||
|
}
|
||||||
155
cli/lib/reviews.ts
Normal file
155
cli/lib/reviews.ts
Normal file
|
|
@ -0,0 +1,155 @@
|
||||||
|
// Store review replies as pure parts: normalising both stores' reviews, the local draft files the owner / agent edit
|
||||||
|
// (.storebound/replies/<store>-<id>.md, front matter + the review + "## Reply"), and the checks a reply must pass
|
||||||
|
// before `storebound reviews send` sends it (only drafts with `approved: true`, after a confirmation).
|
||||||
|
// Sources (checked October 2026):
|
||||||
|
// App Store: GET /v1/apps/{id}/customerReviews, POST /v1/customerReviewResponses (one response per review; a new POST
|
||||||
|
// replaces it; it shows after up to 24 hours) https://developer.apple.com/documentation/appstoreconnectapi/customer-review-responses
|
||||||
|
// Guidance: https://developer.apple.com/app-store/responding-to-reviews/ (no personal info, marketing or spam)
|
||||||
|
// Length: Apple documents no maximum; 5970 characters is the limit App Store Connect is commonly reported to
|
||||||
|
// enforce (NOT VERIFIED), so storebound warns above it instead of blocking.
|
||||||
|
// Google Play: reviews.list returns reviews created or edited in the last week only; reviews.reply {replyText},
|
||||||
|
// at most 350 characters (HTML tags stripped, not counted) https://developers.google.com/android-publisher/reply-to-reviews
|
||||||
|
import { len } from './copy';
|
||||||
|
import { type FmValue, parseFrontMatter, stringifyFrontMatter } from './frontmatter';
|
||||||
|
|
||||||
|
export type ReviewStore = 'apple' | 'play';
|
||||||
|
export const REPLY_LIMITS: Record<ReviewStore, number> = { play: 350, apple: 5970 };
|
||||||
|
|
||||||
|
export interface Review {
|
||||||
|
store: ReviewStore;
|
||||||
|
id: string;
|
||||||
|
rating: number;
|
||||||
|
title?: string;
|
||||||
|
body: string;
|
||||||
|
author?: string;
|
||||||
|
/** Apple: territory (alpha-3); Play: reviewer language. */
|
||||||
|
where?: string;
|
||||||
|
date: string;
|
||||||
|
appVersion?: string;
|
||||||
|
reply?: { text: string; date?: string; state?: string };
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AppleReviewsResp {
|
||||||
|
data?: { id: string; attributes: { rating?: number; title?: string; body?: string; reviewerNickname?: string; createdDate?: string; territory?: string }; relationships?: { response?: { data?: { id: string } | null } } }[];
|
||||||
|
included?: { type: string; id: string; attributes?: { responseBody?: string; lastModifiedDate?: string; state?: string } }[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function parseAppleReviews(resp: AppleReviewsResp): Review[] {
|
||||||
|
const responses = new Map((resp.included ?? []).filter(x => x.type === 'customerReviewResponses').map(x => [x.id, x.attributes ?? {}] as const));
|
||||||
|
return (resp.data ?? []).map(r => {
|
||||||
|
const resp1 = responses.get(r.relationships?.response?.data?.id ?? '');
|
||||||
|
return { store: 'apple' as const, id: r.id, rating: r.attributes.rating ?? 0, title: r.attributes.title || undefined, body: r.attributes.body ?? '',
|
||||||
|
author: r.attributes.reviewerNickname, where: r.attributes.territory, date: r.attributes.createdDate ? new Date(r.attributes.createdDate).toISOString() : '',
|
||||||
|
...(resp1?.responseBody ? { reply: { text: resp1.responseBody, date: resp1.lastModifiedDate, state: resp1.state } } : {}) };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PlayReviewsResp {
|
||||||
|
reviews?: { reviewId: string; authorName?: string; comments?: { userComment?: { text?: string; lastModified?: { seconds?: string }; starRating?: number; reviewerLanguage?: string; appVersionName?: string };
|
||||||
|
developerComment?: { text?: string; lastModified?: { seconds?: string } } }[] }[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const isoFromSeconds = (s?: string) => (s ? new Date(Number(s) * 1000).toISOString() : '');
|
||||||
|
|
||||||
|
export function parsePlayReviews(resp: PlayReviewsResp): Review[] {
|
||||||
|
return (resp.reviews ?? []).map(r => {
|
||||||
|
const u = r.comments?.find(c => c.userComment)?.userComment ?? {};
|
||||||
|
const d = r.comments?.find(c => c.developerComment)?.developerComment;
|
||||||
|
// A review with a separate title comes as "title\tbody".
|
||||||
|
const [title, body] = (u.text ?? '').includes('\t') ? (u.text ?? '').split('\t', 2) as [string, string] : [undefined, u.text ?? ''];
|
||||||
|
return { store: 'play' as const, id: r.reviewId, rating: u.starRating ?? 0, title: title?.trim() || undefined, body: body.trim(), author: r.authorName,
|
||||||
|
where: u.reviewerLanguage, date: isoFromSeconds(u.lastModified?.seconds), appVersion: u.appVersionName,
|
||||||
|
...(d?.text ? { reply: { text: d.text, date: isoFromSeconds(d.lastModified?.seconds) } } : {}) };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reviews newer than `sinceIso`, optional filters, newest first. */
|
||||||
|
export function filterReviews(rs: Review[], o: { since?: string; unanswered?: boolean; ratings?: number[] } = {}): Review[] {
|
||||||
|
return rs.filter(r => (!o.since || r.date >= o.since) && (!o.unanswered || !r.reply) && (!o.ratings?.length || o.ratings.includes(r.rating)))
|
||||||
|
.sort((a, b) => b.date.localeCompare(a.date));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** File name of a draft: <store>-<review id>.md with unsafe characters replaced. */
|
||||||
|
export const draftName = (r: Pick<Review, 'store' | 'id'>): string => `${r.store}-${r.id.replace(/[^A-Za-z0-9._-]/g, '_').slice(0, 120)}.md`;
|
||||||
|
|
||||||
|
export const REPLY_PLACEHOLDER = '<!-- Write the reply below. Plain text, the player\'s language. -->';
|
||||||
|
|
||||||
|
/** A new draft: front matter (approved: false), the review as a quote, an empty "## Reply" section. */
|
||||||
|
export function draftMarkdown(r: Review): string {
|
||||||
|
const quote = (t: string) => t.split('\n').map(l => `> ${l}`).join('\n');
|
||||||
|
const body = [
|
||||||
|
`# ${'★'.repeat(Math.max(0, Math.min(5, r.rating)))}${'☆'.repeat(Math.max(0, 5 - r.rating))} ${r.title ?? ''}`.trimEnd(), '',
|
||||||
|
quote(r.body || '(no text)'), '',
|
||||||
|
`${r.where ? `${r.where} · ` : ''}${r.date.slice(0, 10)}${r.appVersion ? ` · version ${r.appVersion}` : ''}`, '',
|
||||||
|
...(r.reply ? ['## Current reply', '', quote(r.reply.text), ''] : []),
|
||||||
|
'## Reply', '', REPLY_PLACEHOLDER, '', '',
|
||||||
|
].join('\n');
|
||||||
|
const meta: Record<string, FmValue> = { store: r.store, review_id: r.id, rating: r.rating, where: r.where ?? null, date: r.date, limit: REPLY_LIMITS[r.store], approved: false, sent: null };
|
||||||
|
return stringifyFrontMatter(meta, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Draft { file: string; store: ReviewStore; reviewId: string; approved: boolean; sent: string | null; reply: string; meta: Record<string, FmValue> }
|
||||||
|
|
||||||
|
/** A draft file -> its reply text (after "## Reply", HTML comments removed) and state. */
|
||||||
|
export function parseDraft(file: string, text: string): Draft {
|
||||||
|
const { data, body } = parseFrontMatter(text);
|
||||||
|
const store = data.store;
|
||||||
|
if (store !== 'apple' && store !== 'play') throw new Error(`${file}: front matter "store" must be apple or play`);
|
||||||
|
if (!data.review_id) throw new Error(`${file}: front matter "review_id" missing`);
|
||||||
|
const at = body.search(/^## Reply\s*$/m);
|
||||||
|
const reply = at < 0 ? '' : body.slice(at).replace(/^## Reply\s*$/m, '').replace(/<!--[\s\S]*?-->/g, '').trim();
|
||||||
|
return { file, store, reviewId: String(data.review_id), approved: data.approved === true, sent: typeof data.sent === 'string' ? data.sent : null, reply, meta: data };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Front matter `sent: <iso>` (and approved kept) after a successful send. */
|
||||||
|
export function markSent(text: string, iso: string): string {
|
||||||
|
const { data, body } = parseFrontMatter(text);
|
||||||
|
return stringifyFrontMatter({ ...data, sent: iso }, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
const INCENTIVE = [
|
||||||
|
/\b(free|bonus|extra|gift|reward|compensat\w*)\b[^.!?\n]{0,40}\b(coins?|gems?|diamonds?|credits?|lives|items?|currency|refund)\b/i,
|
||||||
|
/\b(change|update|raise|edit|improve|revise)\s+(your\s+)?(rating|review|stars?|score)\b/i,
|
||||||
|
/\b(5|five)[ -]?stars?\b/i,
|
||||||
|
/\b(rate|review)\s+us\b/i,
|
||||||
|
];
|
||||||
|
|
||||||
|
export interface ReplyIssue { level: 'error' | 'warn'; msg: string }
|
||||||
|
|
||||||
|
/** Problems with a reply before sending. Errors block `reviews send`; warnings are shown. */
|
||||||
|
export function checkReply(reply: string, store: ReviewStore): ReplyIssue[] {
|
||||||
|
const e: ReplyIssue[] = [];
|
||||||
|
const text = store === 'play' ? reply.replace(/<[^>]*>/g, '') : reply;
|
||||||
|
if (!text.trim()) e.push({ level: 'error', msg: 'empty reply' });
|
||||||
|
const n = len(text);
|
||||||
|
if (store === 'play' && n > REPLY_LIMITS.play) e.push({ level: 'error', msg: `${n} > ${REPLY_LIMITS.play} characters (Google Play limit)` });
|
||||||
|
if (store === 'apple' && n > REPLY_LIMITS.apple) e.push({ level: 'warn', msg: `${n} characters: App Store Connect is reported to stop at ${REPLY_LIMITS.apple}` });
|
||||||
|
if (INCENTIVE.some(re => re.test(text))) e.push({ level: 'error', msg: 'offers something for a rating or asks to change / give stars: not allowed (no incentives, no rating manipulation)' });
|
||||||
|
if (/[^@\s]+@[^@\s]+\.[a-z]{2,}/i.test(text)) e.push({ level: 'warn', msg: 'contains an email address: only your public support address, never a player\'s' });
|
||||||
|
if (/(\+?\d[\d\s().-]{7,}\d)/.test(text)) e.push({ level: 'warn', msg: 'contains a phone-like number: no personal data in public replies' });
|
||||||
|
if (/https?:\/\//i.test(text)) e.push({ level: 'warn', msg: 'contains a link: support pages only, no marketing' });
|
||||||
|
if (/[A-Z]{6,}/.test(text) || /!{3,}/.test(text)) e.push({ level: 'warn', msg: 'shouting (caps / !!!): keep it calm' });
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Which drafts `send` would send, and why the others are skipped. */
|
||||||
|
export function sendPlan(drafts: Draft[]): { send: Draft[]; skip: { file: string; why: string }[] } {
|
||||||
|
const send: Draft[] = [];
|
||||||
|
const skip: { file: string; why: string }[] = [];
|
||||||
|
for (const d of drafts) {
|
||||||
|
if (d.sent) { skip.push({ file: d.file, why: `already sent ${d.sent.slice(0, 10)}` }); continue; }
|
||||||
|
if (!d.approved) { skip.push({ file: d.file, why: 'not approved (set approved: true after reading it)' }); continue; }
|
||||||
|
const errors = checkReply(d.reply, d.store).filter(i => i.level === 'error');
|
||||||
|
if (errors.length) { skip.push({ file: d.file, why: errors.map(i => i.msg).join('; ') }); continue; }
|
||||||
|
send.push(d);
|
||||||
|
}
|
||||||
|
return { send, skip };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The request that sends one reply. Apple: a POST replaces an earlier response; Play: :reply creates or updates. */
|
||||||
|
export function replyRequest(d: Draft, packageName?: string): { method: 'POST'; url: string; body: unknown } {
|
||||||
|
if (d.store === 'apple') return { method: 'POST', url: '/v1/customerReviewResponses', body: { data: { type: 'customerReviewResponses', attributes: { responseBody: d.reply },
|
||||||
|
relationships: { review: { data: { type: 'customerReviews', id: d.reviewId } } } } } };
|
||||||
|
if (!packageName) throw new Error('play.packageName is not set');
|
||||||
|
return { method: 'POST', url: `https://androidpublisher.googleapis.com/androidpublisher/v3/applications/${packageName}/reviews/${encodeURIComponent(d.reviewId)}:reply`, body: { replyText: d.reply } };
|
||||||
|
}
|
||||||
|
|
@ -50,6 +50,16 @@ export const TOOLS: ToolDef[] = [
|
||||||
description: 'Weekly health summary as Markdown in .storebound/health/<date>.md (plus <date>.json for the next week-over-week comparison). Local files only; dry_run prints the report.',
|
description: 'Weekly health summary as Markdown in .storebound/health/<date>.md (plus <date>.json for the next week-over-week comparison). Local files only; dry_run prints the report.',
|
||||||
props: { store: { type: 'string', enum: ['both', 'apple', 'play'], default: 'both' } },
|
props: { store: { type: 'string', enum: ['both', 'apple', 'play'], default: 'both' } },
|
||||||
args: i => (i.store === 'apple' ? ['--apple'] : i.store === 'play' ? ['--play'] : []) },
|
args: i => (i.store === 'apple' ? ['--apple'] : i.store === 'play' ? ['--play'] : []) },
|
||||||
|
{ name: 'reviews_list', title: 'Store reviews', command: ['reviews', 'list'], write: false, network: true,
|
||||||
|
description: 'Read-only list of recent App Store and Google Play reviews (date, stars, territory / language, replied or not, text). Google Play only returns reviews from the last 7 days.',
|
||||||
|
props: { store: { type: 'string', enum: ['apple', 'play'], description: 'Default: both' }, days: { type: 'integer', minimum: 1, maximum: 365, default: 14 },
|
||||||
|
unanswered: { type: 'boolean', default: false }, rating: { type: 'string', pattern: '^[1-5](,[1-5])*$', description: 'e.g. 1,2' } },
|
||||||
|
args: i => [...opt('store', i.store), ...opt('days', i.days), ...flag('unanswered', i.unanswered), ...opt('rating', i.rating)] },
|
||||||
|
{ name: 'reviews_draft', title: 'Draft review replies', command: ['reviews', 'draft'], write: true, network: true, idempotent: true,
|
||||||
|
description: 'Write one local Markdown draft per unanswered review into .storebound/replies/<store>-<id>.md (approved: false; existing drafts are kept). Then write the reply under "## Reply" following the review-replies skill; the owner approves and sends from the terminal. Nothing is sent to a store.',
|
||||||
|
props: { store: { type: 'string', enum: ['apple', 'play'], description: 'Default: both' }, days: { type: 'integer', minimum: 1, maximum: 365, default: 14 },
|
||||||
|
rating: { type: 'string', pattern: '^[1-5](,[1-5])*$', description: 'Only these star ratings, e.g. 1,2,3' } },
|
||||||
|
args: i => [...opt('store', i.store), ...opt('days', i.days), ...opt('rating', i.rating)] },
|
||||||
{ name: 'apple_status', title: 'App Store status', command: ['apple', 'status'], write: false, network: true,
|
{ name: 'apple_status', title: 'App Store status', command: ['apple', 'status'], write: false, network: true,
|
||||||
description: 'Read-only App Store Connect overview: versions and their states, recent builds, in-app purchases, review submissions.' },
|
description: 'Read-only App Store Connect overview: versions and their states, recent builds, in-app purchases, review submissions.' },
|
||||||
{ name: 'apple_next_build', title: 'Next iOS build number', command: ['apple', 'next-build'], write: false, network: true,
|
{ name: 'apple_next_build', title: 'Next iOS build number', command: ['apple', 'next-build'], write: false, network: true,
|
||||||
|
|
@ -159,7 +169,7 @@ export const TOOLS: ToolDef[] = [
|
||||||
|
|
||||||
/** CLI flags / commands that must never be reachable through MCP. Tests assert none of the tools can produce them. */
|
/** CLI flags / commands that must never be reachable through MCP. Tests assert none of the tools can produce them. */
|
||||||
export const FORBIDDEN_ARGS = ['--yes', '--manual-release', '--cancel-submission', '--production', 'rollout', 'resume', 'complete',
|
export const FORBIDDEN_ARGS = ['--yes', '--manual-release', '--cancel-submission', '--production', 'rollout', 'resume', 'complete',
|
||||||
'--submit-review', '--remove', '--invite', 'testers'];
|
'--submit-review', '--remove', '--invite', 'testers', 'send'];
|
||||||
|
|
||||||
export function inputSchema(t: ToolDef): Record<string, unknown> {
|
export function inputSchema(t: ToolDef): Record<string, unknown> {
|
||||||
const props: Record<string, JsonSchema> = { ...(t.props ?? {}) };
|
const props: Record<string, JsonSchema> = { ...(t.props ?? {}) };
|
||||||
|
|
|
||||||
143
cli/reviews.ts
Normal file
143
cli/reviews.ts
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
// Store reviews and replies.
|
||||||
|
// storebound reviews list [--store apple|play] [--days 14] [--unanswered] [--rating 1,2] [--json]
|
||||||
|
// storebound reviews draft [--store apple|play] [--days 14] [--rating 1,2,3] [--all] [--dir .storebound/replies] [--dry]
|
||||||
|
// storebound reviews send [--dir .storebound/replies] [--dry] [--yes]
|
||||||
|
// `draft` writes one Markdown file per unanswered review into .storebound/replies/ (gitignored): front matter
|
||||||
|
// (store, review_id, rating, approved: false), the review, and an empty "## Reply" section. Existing files are never
|
||||||
|
// overwritten (your edits stay). The owner or an agent with the review-replies skill writes the reply; the owner sets
|
||||||
|
// `approved: true`. `send` sends only approved, unsent drafts that pass the checks (length, no incentives), after a
|
||||||
|
// confirmation, then writes `sent: <time>` into the file. Replies are public: `send` is not an MCP tool.
|
||||||
|
// Google Play's API only returns reviews created or edited in the last 7 days.
|
||||||
|
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
import { ascClient, type J } from './apple/asc';
|
||||||
|
import type { Ctx } from './lib/ctx';
|
||||||
|
import { confirm } from './lib/ctx';
|
||||||
|
import { done, log, warn } from './lib/log';
|
||||||
|
import {
|
||||||
|
checkReply, type Draft, draftMarkdown, draftName, filterReviews, markSent, parseAppleReviews, parseDraft, parsePlayReviews, replyRequest,
|
||||||
|
type Review, sendPlan,
|
||||||
|
} from './lib/reviews';
|
||||||
|
import { textTable } from './lib/table';
|
||||||
|
import { playClient } from './play/client';
|
||||||
|
|
||||||
|
const TAG = 'reviews';
|
||||||
|
|
||||||
|
async function appleReviews(ctx: Ctx, since: string): Promise<Review[]> {
|
||||||
|
const { config, root } = ctx.loaded;
|
||||||
|
const c = await ascClient(root, config.apple!.bundleId, config.apple?.appId);
|
||||||
|
const out: Review[] = [];
|
||||||
|
let url: string | null = `/v1/apps/${await c.app()}/customerReviews?sort=-createdDate&include=response&limit=200`;
|
||||||
|
while (url) {
|
||||||
|
const page: J = await c.asc('GET', url);
|
||||||
|
const rs = parseAppleReviews(page);
|
||||||
|
out.push(...rs);
|
||||||
|
if (!rs.length || rs.at(-1)!.date < since) break;
|
||||||
|
url = page.links?.next ?? null;
|
||||||
|
}
|
||||||
|
log(TAG, `apple: ${out.length} reviews read`);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function playReviews(ctx: Ctx): Promise<Review[]> {
|
||||||
|
const { config, root } = ctx.loaded;
|
||||||
|
const play = await playClient(root, config.play!.packageName);
|
||||||
|
const out: Review[] = [];
|
||||||
|
let token = '';
|
||||||
|
do {
|
||||||
|
const r = await play.call<{ reviews?: unknown[]; tokenPagination?: { nextPageToken?: string } }>('GET', `${play.API}/reviews?maxResults=100${token ? `&token=${encodeURIComponent(token)}` : ''}`);
|
||||||
|
out.push(...parsePlayReviews(r as Parameters<typeof parsePlayReviews>[0]));
|
||||||
|
token = r.tokenPagination?.nextPageToken ?? '';
|
||||||
|
} while (token);
|
||||||
|
log(TAG, `play: ${out.length} reviews read (the API covers the last 7 days)`);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function collect(ctx: Ctx, o: { since: string; unanswered: boolean; ratings: number[] }): Promise<Review[]> {
|
||||||
|
const { config } = ctx.loaded;
|
||||||
|
const store = ctx.args.get('store');
|
||||||
|
if (store && store !== 'apple' && store !== 'play') throw new Error('--store apple | play');
|
||||||
|
const all: Review[] = [];
|
||||||
|
if ((!store || store === 'apple') && config.apple) {
|
||||||
|
try { all.push(...await appleReviews(ctx, o.since)); } catch (e) { if (store) throw e; warn(TAG, `apple: ${(e as Error).message.slice(0, 200)}`); }
|
||||||
|
}
|
||||||
|
if ((!store || store === 'play') && config.play) {
|
||||||
|
try { all.push(...await playReviews(ctx)); } catch (e) { if (store) throw e; warn(TAG, `play: ${(e as Error).message.slice(0, 200)}`); }
|
||||||
|
}
|
||||||
|
return filterReviews(all, o);
|
||||||
|
}
|
||||||
|
|
||||||
|
const snippet = (r: Review) => `${r.title ? r.title + ': ' : ''}${r.body}`.replace(/\s+/g, ' ').slice(0, 70);
|
||||||
|
|
||||||
|
function readDrafts(dir: string): { drafts: Draft[]; texts: Map<string, string> } {
|
||||||
|
const texts = new Map<string, string>();
|
||||||
|
const drafts: Draft[] = [];
|
||||||
|
if (!existsSync(dir)) return { drafts, texts };
|
||||||
|
for (const f of readdirSync(dir).filter(n => /^(apple|play)-.+\.md$/.test(n)).sort()) {
|
||||||
|
const p = join(dir, f);
|
||||||
|
const t = readFileSync(p, 'utf8');
|
||||||
|
texts.set(p, t);
|
||||||
|
try { drafts.push(parseDraft(p, t)); } catch (e) { warn(TAG, (e as Error).message); }
|
||||||
|
}
|
||||||
|
return { drafts, texts };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function run(ctx: Ctx): Promise<void> {
|
||||||
|
const a = ctx.args;
|
||||||
|
const sub = a._[0];
|
||||||
|
const dir = ctx.loaded.resolve(a.get('dir') ?? '.storebound/replies');
|
||||||
|
const days = a.num('days', 14);
|
||||||
|
const since = new Date(Date.now() - days * 86_400_000).toISOString();
|
||||||
|
const ratings = a.list('rating').map(Number).filter(n => n >= 1 && n <= 5);
|
||||||
|
|
||||||
|
if (sub === 'list') {
|
||||||
|
const rs = await collect(ctx, { since, unanswered: a.has('unanswered'), ratings });
|
||||||
|
if (a.has('json')) { console.log(JSON.stringify(rs.map(({ author: _a, ...r }) => r), null, 2)); return; }
|
||||||
|
console.log(textTable(['store', 'date', 'stars', 'where', 'replied', 'review'], rs.map(r => [r.store, r.date.slice(0, 10), r.rating, r.where ?? '', r.reply ? 'yes' : '', snippet(r)])));
|
||||||
|
done(TAG, `${rs.length} review(s) in the last ${days} days, ${rs.filter(r => !r.reply).length} without a reply`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sub === 'draft') {
|
||||||
|
const rs = await collect(ctx, { since, unanswered: !a.has('all'), ratings });
|
||||||
|
let made = 0, kept = 0;
|
||||||
|
if (!a.has('dry')) mkdirSync(dir, { recursive: true });
|
||||||
|
for (const r of rs) {
|
||||||
|
const p = join(dir, draftName(r));
|
||||||
|
if (existsSync(p)) { kept++; continue; }
|
||||||
|
if (a.has('dry')) log(TAG, `would write ${p}`);
|
||||||
|
else writeFileSync(p, draftMarkdown(r));
|
||||||
|
made++;
|
||||||
|
}
|
||||||
|
done(TAG, `${made} new draft(s)${a.has('dry') ? ' (dry run)' : ''}, ${kept} kept as they are, in ${dir}. Next: write each "## Reply", set approved: true, then storebound reviews send`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sub === 'send') {
|
||||||
|
const { drafts, texts } = readDrafts(dir);
|
||||||
|
const plan = sendPlan(drafts);
|
||||||
|
for (const s of plan.skip) log(TAG, `skip ${s.file.split('/').pop()}: ${s.why}`);
|
||||||
|
for (const d of plan.send) for (const i of checkReply(d.reply, d.store)) warn(TAG, `${d.file.split('/').pop()}: ${i.msg}`);
|
||||||
|
if (!plan.send.length) { done(TAG, 'nothing to send'); return; }
|
||||||
|
console.log(textTable(['store', 'review', 'chars', 'reply'], plan.send.map(d => [d.store, d.reviewId, [...d.reply].length, d.reply.replace(/\s+/g, ' ').slice(0, 70)])));
|
||||||
|
if (a.has('dry')) { done(TAG, `${plan.send.length} reply(ies) would be sent (dry run)`); return; }
|
||||||
|
if (!(await confirm(ctx, `Send ${plan.send.length} public reply(ies)? Players are notified and the replies show on the store.`))) return;
|
||||||
|
const { config, root } = ctx.loaded;
|
||||||
|
const c = plan.send.some(d => d.store === 'apple') ? await ascClient(root, config.apple!.bundleId, config.apple?.appId) : null;
|
||||||
|
const play = plan.send.some(d => d.store === 'play') ? await playClient(root, config.play!.packageName) : null;
|
||||||
|
let sent = 0;
|
||||||
|
for (const d of plan.send) {
|
||||||
|
const req = replyRequest(d, config.play?.packageName);
|
||||||
|
try {
|
||||||
|
if (d.store === 'apple') await c!.asc(req.method, req.url, req.body);
|
||||||
|
else await play!.call(req.method, req.url, req.body);
|
||||||
|
writeFileSync(d.file, markSent(texts.get(d.file)!, new Date().toISOString()));
|
||||||
|
sent++;
|
||||||
|
log(TAG, `sent ${d.file.split('/').pop()}`);
|
||||||
|
} catch (e) { warn(TAG, `${d.file.split('/').pop()}: ${(e as Error).message.slice(0, 300)}`); }
|
||||||
|
}
|
||||||
|
done(TAG, `${sent}/${plan.send.length} sent (Apple shows replies within about 24 hours)`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new Error('usage: storebound reviews list | draft | send');
|
||||||
|
}
|
||||||
54
skills/review-replies/SKILL.md
Normal file
54
skills/review-replies/SKILL.md
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
---
|
||||||
|
name: review-replies
|
||||||
|
description: Reply to App Store and Google Play reviews of a mobile game the safe way - list new reviews, write reply drafts into local files (.storebound/replies), keep the tone human and short, never offer incentives or ask for a better rating, respect the store limits (Play 350 characters), and send only drafts the owner approved. Use when the user asks to answer reviews, handle bad ratings, or check what players are saying.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Review replies
|
||||||
|
|
||||||
|
CLI: `storebound reviews list | draft | send`. MCP: `reviews_list` (read-only) and `reviews_draft` (local files).
|
||||||
|
**Sending is the owner's step**: `storebound reviews send` in a terminal, after reading the drafts; it is not an MCP
|
||||||
|
tool, and an agent never sets `approved: true` by itself.
|
||||||
|
|
||||||
|
## Flow
|
||||||
|
1. `storebound reviews list --unanswered` (or `--rating 1,2`): what came in. Google Play's API only returns reviews
|
||||||
|
created or edited in the **last 7 days**, so run this weekly; the App Store keeps the full history.
|
||||||
|
2. `storebound reviews draft` writes `.storebound/replies/<store>-<review id>.md` per unanswered review (gitignored;
|
||||||
|
existing drafts are never overwritten). Front matter: `store`, `review_id`, `rating`, `where` (territory or
|
||||||
|
language), `limit`, `approved: false`, `sent: null`. Below it the review, then `## Reply`.
|
||||||
|
3. Write each reply under `## Reply` (the agent drafts, the owner edits). Then show the owner the list of drafts.
|
||||||
|
4. The owner sets `approved: true` on the ones to send and runs `storebound reviews send --dry`, then
|
||||||
|
`storebound reviews send` (asks for confirmation). Sent files get `sent: <time>`; re-running skips them.
|
||||||
|
|
||||||
|
## How to write a reply
|
||||||
|
- **In the reviewer's language** (`where`: Play gives the language, Apple the territory; when unsure, mirror the
|
||||||
|
review's language).
|
||||||
|
- **Short and specific**: thank them in one line, answer the actual point, say what changed or what to do. Play
|
||||||
|
allows **350 characters** (HTML is stripped); App Store replies can be longer but rarely should be.
|
||||||
|
- **Bug reports**: name the fix and the version if it is released ("Version 1.2.1 fixes the crash on level 3"); if
|
||||||
|
not, say it is known and being worked on, without dates you cannot keep. Point to in-game Settings > Support or the
|
||||||
|
public support page for details.
|
||||||
|
- **Ads / difficulty / price complaints**: explain the option that exists (e.g. "Remove Ads" in the shop, a setting),
|
||||||
|
no argument, no blame.
|
||||||
|
- **Positive reviews**: a short thanks is enough; do not answer every 5-star review with the same template.
|
||||||
|
- One reply per review. A new send replaces the old one (both stores); the reviewer is notified and may update
|
||||||
|
their review on their own.
|
||||||
|
|
||||||
|
## Never (store policy, and storebound blocks the obvious cases)
|
||||||
|
- **No incentives** for ratings or review changes: no coins, gems, items, discounts or refunds "for" a better review,
|
||||||
|
and no "please give us 5 stars" / "update your rating". Google Play prohibits incentivized or manipulated ratings
|
||||||
|
(Play Console Help, "User Ratings, Reviews, and Installs", answer 9898684); Apple removes apps that manipulate
|
||||||
|
reviews or ratings (App Review Guidelines, Developer Code of Conduct). `reviews send` refuses replies that match
|
||||||
|
these patterns.
|
||||||
|
- **No personal data**: no player names beyond what the store shows, no emails or phone numbers of players, no
|
||||||
|
account details. Your public support address is fine.
|
||||||
|
- **No marketing or spam**: no promo codes, no links to other games, no all-caps or "!!!" (Apple's guidance:
|
||||||
|
https://developer.apple.com/app-store/responding-to-reviews/).
|
||||||
|
- **No arguing or disclosing**: do not dispute facts publicly, do not reveal internal plans, cheats or how anti-cheat
|
||||||
|
works. Hostile or abusive reviews: skip or keep it to one polite line; report policy-violating reviews in the console.
|
||||||
|
|
||||||
|
## Gotchas
|
||||||
|
- Apple shows a reply after up to about 24 hours (`PENDING_PUBLISH` first). Apple documents no maximum length;
|
||||||
|
storebound warns above 5970 characters (commonly reported App Store Connect limit, not verified).
|
||||||
|
- Replying needs the Account Holder, Admin or Customer Support role on Apple's side and the "Reply to reviews"
|
||||||
|
permission for the Play service account.
|
||||||
|
- Drafts contain public reviewer nicknames: keep `.storebound/` out of git (it is gitignored by `storebound init`).
|
||||||
106
tests/reviews.test.ts
Normal file
106
tests/reviews.test.ts
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
import { describe, expect, test } from 'bun:test';
|
||||||
|
import { parseFrontMatter, stringifyFrontMatter } from '../cli/lib/frontmatter';
|
||||||
|
import {
|
||||||
|
checkReply, draftMarkdown, draftName, filterReviews, markSent, parseAppleReviews, parseDraft, parsePlayReviews, REPLY_LIMITS, REPLY_PLACEHOLDER,
|
||||||
|
replyRequest, sendPlan,
|
||||||
|
} from '../cli/lib/reviews';
|
||||||
|
import { FORBIDDEN_ARGS, TOOLS, toArgv } from '../cli/mcp-tools';
|
||||||
|
|
||||||
|
const appleResp = {
|
||||||
|
data: [
|
||||||
|
{ id: 'r1', attributes: { rating: 2, title: 'Too many ads', body: 'Fun but ads after every level.', reviewerNickname: 'nick1', createdDate: '2026-10-08T09:00:00-07:00', territory: 'USA' }, relationships: { response: { data: { id: 'resp1' } } } },
|
||||||
|
{ id: 'r2', attributes: { rating: 5, title: '', body: 'Love it', reviewerNickname: 'nick2', createdDate: '2026-10-09T09:00:00-07:00', territory: 'TUR' }, relationships: { response: { data: null } } },
|
||||||
|
],
|
||||||
|
included: [{ type: 'customerReviewResponses', id: 'resp1', attributes: { responseBody: 'Thanks!', lastModifiedDate: '2026-10-08T12:00:00-07:00', state: 'PUBLISHED' } }],
|
||||||
|
};
|
||||||
|
const playResp = {
|
||||||
|
reviews: [{ reviewId: 'gp:AOqp-1', authorName: 'A Player', comments: [
|
||||||
|
{ userComment: { text: 'Crashes\tIt crashes on level 3.', lastModified: { seconds: '1791300000' }, starRating: 1, reviewerLanguage: 'en', appVersionName: '1.2.0' } },
|
||||||
|
{ developerComment: { text: 'Sorry, fixed in 1.2.1.', lastModified: { seconds: '1791400000' } } }] },
|
||||||
|
{ reviewId: 'gp:AOqp-2', comments: [{ userComment: { text: 'Nice game', lastModified: { seconds: '1791200000' }, starRating: 4, reviewerLanguage: 'tr' } }] }],
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('front matter', () => {
|
||||||
|
test('round trip with quoting', () => {
|
||||||
|
const t = stringifyFrontMatter({ store: 'play', review_id: 'gp:AOqp-1', rating: 1, approved: false, sent: null, note: 'a: b, "c"' }, 'body\n');
|
||||||
|
expect(t.startsWith('---\nstore: play\nreview_id: gp:AOqp-1\nrating: 1\napproved: false\nsent: null\nnote: "a: b, \\"c\\""\n---\n')).toBe(true);
|
||||||
|
expect(parseFrontMatter(t).data).toEqual({ store: 'play', review_id: 'gp:AOqp-1', rating: 1, approved: false, sent: null, note: 'a: b, "c"' });
|
||||||
|
expect(parseFrontMatter('no front matter').body).toBe('no front matter');
|
||||||
|
expect(parseFrontMatter('---\nx: \'it\'\'s\'\ny: true\n---\n').data).toEqual({ x: "it's", y: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('reviews', () => {
|
||||||
|
test('apple and play responses normalise to one shape', () => {
|
||||||
|
const a = parseAppleReviews(appleResp);
|
||||||
|
expect(a[0]).toMatchObject({ store: 'apple', id: 'r1', rating: 2, title: 'Too many ads', where: 'USA', reply: { text: 'Thanks!', state: 'PUBLISHED' } });
|
||||||
|
expect(a[1]!.title).toBeUndefined();
|
||||||
|
expect(a[1]!.reply).toBeUndefined();
|
||||||
|
const p = parsePlayReviews(playResp);
|
||||||
|
expect(p[0]).toMatchObject({ store: 'play', id: 'gp:AOqp-1', rating: 1, title: 'Crashes', body: 'It crashes on level 3.', where: 'en', appVersion: '1.2.0', reply: { text: 'Sorry, fixed in 1.2.1.' } });
|
||||||
|
expect(p[0]!.date).toBe(new Date(1791300000 * 1000).toISOString());
|
||||||
|
expect(p[1]).toMatchObject({ body: 'Nice game', rating: 4 });
|
||||||
|
const all = [...a, ...p];
|
||||||
|
expect(filterReviews(all, { unanswered: true }).map(r => r.id)).toEqual(['r2', 'gp:AOqp-2']);
|
||||||
|
expect(filterReviews(all, { ratings: [1, 2] }).map(r => r.id).sort()).toEqual(['gp:AOqp-1', 'r1']);
|
||||||
|
expect(filterReviews(all, { since: '2026-10-09' }).map(r => r.id)).toEqual(['r2']);
|
||||||
|
});
|
||||||
|
test('draft file: name, front matter, quote, empty reply; parse back', () => {
|
||||||
|
const r = parsePlayReviews(playResp)[0]!;
|
||||||
|
expect(draftName(r)).toBe('play-gp_AOqp-1.md');
|
||||||
|
const md = draftMarkdown(r);
|
||||||
|
expect(md).toContain('approved: false');
|
||||||
|
expect(md).toContain('limit: 350');
|
||||||
|
expect(md).toContain('> It crashes on level 3.');
|
||||||
|
expect(md).toContain('## Current reply');
|
||||||
|
expect(md).toContain(REPLY_PLACEHOLDER);
|
||||||
|
const d = parseDraft('x.md', md);
|
||||||
|
expect(d).toMatchObject({ store: 'play', reviewId: 'gp:AOqp-1', approved: false, sent: null, reply: '' });
|
||||||
|
const filled = md.replace(REPLY_PLACEHOLDER, 'Thanks for telling us. Version 1.2.1 fixes the crash on level 3.').replace('approved: false', 'approved: true');
|
||||||
|
const d2 = parseDraft('x.md', filled);
|
||||||
|
expect(d2.reply).toBe('Thanks for telling us. Version 1.2.1 fixes the crash on level 3.');
|
||||||
|
expect(d2.approved).toBe(true);
|
||||||
|
const sent = markSent(filled, '2026-10-10T10:00:00.000Z');
|
||||||
|
expect(parseDraft('x.md', sent).sent).toBe('2026-10-10T10:00:00.000Z');
|
||||||
|
expect(() => parseDraft('bad.md', '---\nstore: web\n---\n')).toThrow('apple or play');
|
||||||
|
});
|
||||||
|
test('reply checks: limits, incentives, personal data, tone', () => {
|
||||||
|
expect(REPLY_LIMITS).toEqual({ play: 350, apple: 5970 });
|
||||||
|
expect(checkReply('Thanks! We fixed it in 1.2.1.', 'play')).toEqual([]);
|
||||||
|
expect(checkReply('', 'apple')[0]).toEqual({ level: 'error', msg: 'empty reply' });
|
||||||
|
expect(checkReply('x'.repeat(351), 'play')[0]!.level).toBe('error');
|
||||||
|
expect(checkReply('<b>' + 'x'.repeat(350) + '</b>', 'play')).toEqual([]);
|
||||||
|
expect(checkReply('x'.repeat(5971), 'apple')[0]!.level).toBe('warn');
|
||||||
|
for (const bad of ['Update your rating and get 500 free coins!', 'Please give us 5 stars', 'Could you change your review?', 'We will send you free gems', 'Rate us again'])
|
||||||
|
expect({ bad, err: checkReply(bad, 'apple').some(i => i.level === 'error') }).toEqual({ bad, err: true });
|
||||||
|
expect(checkReply('Write to support@example.com', 'apple')[0]!.level).toBe('warn');
|
||||||
|
expect(checkReply('Call +1 555 010 0199', 'apple')[0]!.msg).toContain('phone');
|
||||||
|
expect(checkReply('See https://example.com/help', 'apple')[0]!.msg).toContain('link');
|
||||||
|
expect(checkReply('SORRY!!!', 'apple').some(i => i.msg.includes('shouting'))).toBe(true);
|
||||||
|
});
|
||||||
|
test('send plan: only approved, unsent, passing drafts; requests per store', () => {
|
||||||
|
const base = { meta: {}, file: 'f' };
|
||||||
|
const plan = sendPlan([
|
||||||
|
{ ...base, file: 'a', store: 'apple', reviewId: 'r1', approved: true, sent: null, reply: 'Thanks for the feedback, we cut the ads in 1.3.' },
|
||||||
|
{ ...base, file: 'b', store: 'play', reviewId: 'p1', approved: false, sent: null, reply: 'ok' },
|
||||||
|
{ ...base, file: 'c', store: 'play', reviewId: 'p2', approved: true, sent: '2026-10-01T00:00:00Z', reply: 'ok' },
|
||||||
|
{ ...base, file: 'd', store: 'play', reviewId: 'p3', approved: true, sent: null, reply: 'Give us 5 stars for free coins' },
|
||||||
|
]);
|
||||||
|
expect(plan.send.map(d => d.file)).toEqual(['a']);
|
||||||
|
expect(plan.skip.map(s => s.file)).toEqual(['b', 'c', 'd']);
|
||||||
|
expect(plan.skip[0]!.why).toContain('not approved');
|
||||||
|
expect(plan.skip[2]!.why).toContain('incentives');
|
||||||
|
expect(replyRequest(plan.send[0]!)).toEqual({ method: 'POST', url: '/v1/customerReviewResponses', body: { data: { type: 'customerReviewResponses', attributes: { responseBody: 'Thanks for the feedback, we cut the ads in 1.3.' }, relationships: { review: { data: { type: 'customerReviews', id: 'r1' } } } } } });
|
||||||
|
const pr = replyRequest({ ...base, store: 'play', reviewId: 'gp:AOqp-1', approved: true, sent: null, reply: 'Hi' }, 'com.example.game');
|
||||||
|
expect(pr.url).toBe('https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.example.game/reviews/gp%3AAOqp-1:reply');
|
||||||
|
expect(pr.body).toEqual({ replyText: 'Hi' });
|
||||||
|
});
|
||||||
|
test('mcp: list + draft only, never send', () => {
|
||||||
|
const t = (n: string) => TOOLS.find(x => x.name === n)!;
|
||||||
|
expect(t('reviews_list')).toMatchObject({ write: false });
|
||||||
|
expect(toArgv(t('reviews_list'), { store: 'play', unanswered: true, rating: '1,2' }).argv).toEqual(['reviews', 'list', '--store', 'play', '--unanswered', '--rating', '1,2']);
|
||||||
|
expect(toArgv(t('reviews_draft'), { days: 7 }).argv).toEqual(['reviews', 'draft', '--days', '7', '--dry']);
|
||||||
|
expect(FORBIDDEN_ARGS).toContain('send');
|
||||||
|
expect(TOOLS.some(x => x.command.includes('send'))).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue