From 41b92dfa13626c397ca02f07f9ad8a71876dafce Mon Sep 17 00:00:00 2001 From: CRT Date: Sun, 11 Oct 2026 18:14:27 +0000 Subject: [PATCH] aso: App Store keyword fill hint and limit both count UTF-8 bytes (non-Latin locales were warned to add characters that would break the 100-byte limit) --- cli/lib/aso.ts | 8 +++++--- tests/wave1.test.ts | 10 +++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cli/lib/aso.ts b/cli/lib/aso.ts index 190910bb..d2a33005 100644 --- a/cli/lib/aso.ts +++ b/cli/lib/aso.ts @@ -27,10 +27,12 @@ export function auditAppleKeywords(locale: string, c: AppleCopy, appName: string const at = `apple ${locale}`; const kw = c.keywords ?? ''; if (!kw) return [{ level: 'error', where: at, msg: 'keywords: empty' }]; - const chars = len(kw); - if (chars > 100) out.push({ level: 'error', where: at, msg: `keywords: ${chars} characters > 100` }); + // App Store Connect limits the keyword field to 100 bytes (UTF-8), not characters: Cyrillic, Arabic, Hindi, Thai, + // Japanese, Korean and Chinese words take 2-3 bytes per character, so both the limit and the fill hint count bytes. + const bytes = Buffer.byteLength(kw, 'utf8'); + if (bytes > 100) out.push({ level: 'error', where: at, msg: `keywords: ${bytes} bytes > 100` }); if (/,\s|\s,/.test(kw)) out.push({ level: 'error', where: at, msg: 'keywords: spaces around commas waste characters' }); - if (chars < 90) out.push({ level: 'warn', where: at, msg: `keywords: ${chars}/100 used; fill at least 90 (${100 - chars} characters free)` }); + if (bytes < 90) out.push({ level: 'warn', where: at, msg: `keywords: ${bytes}/100 bytes used; fill at least 90 (${100 - bytes} bytes free)` }); const terms = kw.split(',').map(t => t.trim().toLocaleLowerCase(locale)).filter(Boolean); const seen = new Set(); for (const t of terms) { diff --git a/tests/wave1.test.ts b/tests/wave1.test.ts index d015ee5c..c1f1a85c 100644 --- a/tests/wave1.test.ts +++ b/tests/wave1.test.ts @@ -148,10 +148,18 @@ describe('mcp: screenshot and video tools', () => { }); describe('aso', () => { + test('App Store keywords count bytes, not characters (limit and fill hint)', () => { + const msgs = (kw: string) => auditAppleKeywords('ru', { keywords: kw } as never, 'X').map(f => f.msg); + const short = 'игра,бег,прыжки,монеты,уровни,рекорд,аркада'; // 43 characters, 80 bytes + expect(msgs(short).some(m => m.includes('80/100 bytes') && m.includes('fill at least 90'))).toBe(true); + const full = short + ',быстро'; // 50 characters but 93 bytes: full enough + expect(msgs(full).some(m => m.includes('fill at least 90'))).toBe(false); + expect(msgs(full + ',звук').some(m => m.includes('102 bytes > 100'))).toBe(true); + }); test('keyword field rules', () => { const f = auditAppleKeywords('en-US', { subtitle: 'Relaxing puzzle', keywords: 'match,puzzle,match,free game' }, 'Tile Match'); const text = f.map(x => `${x.level}:${x.msg}`).join('\n'); - expect(text).toContain('warn:keywords: 28/100 used'); + expect(text).toContain('warn:keywords: 28/100 bytes used'); expect(text).toContain('"match" listed twice'); expect(text).toContain('repeat words from the name / subtitle (already indexed): match, puzzle'); expect(text).toContain('filler words that rarely help: free, game');