serve --stdio: desktop JSON-RPC profile on the MCP core, confirm tokens, --json results, sidecar builds

- cli/serve.ts: session.hello with a per-session secret, typed methods per tool, project.inspect,
  portfolio.status over many project folders, progress notifications, cancellation
- cli/lib/confirm-token.ts: single-use HMAC tokens bound to method + canonical params + expiry;
  writes are dry runs without one; no submit / release / publish method exists
- cli/lib/runner.ts: shared child runner for mcp and serve, works from a compiled binary
- --json on check, testflight / ppo status, next-build, next-version-code, analytics compare,
  prices import; inspect command; confirm() always answers no under serve
- tools/build-sidecars.ts: bun build --compile for five targets, ad-hoc re-sign on macOS, path leak check
- tests/serve.test.ts: methods, token binding / expiry / replay, shared vector, stdio and compiled smoke
This commit is contained in:
CRTkafa 2026-10-10 17:11:56 +00:00
parent c6360812b8
commit 3454a9aadb
28 changed files with 1048 additions and 42 deletions

View file

@ -3,6 +3,7 @@
// subscriptions + terms URL) and the files the config points at. No network; credentials are only checked for presence.
// storebound check everything above
// storebound check --aso keyword audit of both listing files (App Store keyword field, Play stuffing); exit 1 on errors
// --json structured result ({ ok, items, warnings, problems } or { findings, errors }), exit 1 on problems
import { existsSync, readFileSync } from 'node:fs';
import { type AsoFinding, auditAso } from './lib/aso';
import { playCodes } from './lib/config';
@ -10,7 +11,7 @@ import { APPLE_IAP_LIMITS, len, parseAppStoreListing, parsePlayListing } from '.
import type { Ctx } from './lib/ctx';
import { dataSafetyRows } from './lib/data-safety';
import { reviewDemoAccount } from './lib/credentials';
import { log, warn } from './lib/log';
import { log, printJson, warn } from './lib/log';
import { profileIssues } from './lib/profile';
import { allSubscriptions } from './lib/subscriptions';
import { type CopyFile, validateCopy } from './shots/lib';
@ -20,6 +21,7 @@ function aso(ctx: Ctx): void {
const apple = config.apple ? parseAppStoreListing(readFileSync(resolve(config.apple.listing ?? 'store/appstore.md'), 'utf8')) : undefined;
const play = config.play ? parsePlayListing(readFileSync(resolve(config.play.listing ?? 'store/listing.md'), 'utf8'), config.app.name) : undefined;
const f: AsoFinding[] = auditAso({ apple, play, appName: config.app.name, storefront: ctx.args.get('storefront') ?? 'US' });
if (ctx.args.has('json')) { const errors = f.filter(x => x.level === 'error').length; printJson({ findings: f, errors }); if (errors) process.exitCode = 1; return; }
const tag = { error: 'ERROR', warn: 'warn ', info: 'info ' } as const;
for (const x of f) console.log(`${tag[x.level]} [${x.where}] ${x.msg}`);
const errors = f.filter(x => x.level === 'error').length;
@ -32,24 +34,29 @@ export async function run(ctx: Ctx): Promise<void> {
const { config, resolve, path } = ctx.loaded;
log('check', `config ok: ${path}`);
const problems: string[] = [];
const tryDo = (what: string, fn: () => string): void => { try { log('check', `${what}: ${fn()}`); } catch (e) { problems.push(`${what}: ${(e as Error).message}`); } };
const items: { what: string; detail: string }[] = [];
const warnings: string[] = [];
const note = (msg: string): void => { warnings.push(msg); warn('check', msg); };
const tryDo = (what: string, fn: () => string): void => {
try { const detail = fn(); items.push({ what, detail }); log('check', `${what}: ${detail}`); } catch (e) { problems.push(`${what}: ${(e as Error).message}`); }
};
if (config.play) tryDo('play listing', () => {
const f = resolve(config.play!.listing ?? 'store/listing.md');
const copy = parsePlayListing(readFileSync(f, 'utf8'), config.app.name);
const want = config.languages.flatMap(playCodes);
const missing = want.filter(c => !copy.some(x => x.lang === c));
if (missing.length) warn('check', `play listing has no section for ${missing.join(', ')}`);
if (missing.length) note(`play listing has no section for ${missing.join(', ')}`);
const def = copy.find(x => x.lang === (config.play!.defaultLanguage ?? 'en-US'));
const same = copy.filter(x => def && x !== def && x.whatsNew && x.whatsNew === def.whatsNew && x.lang.slice(0, 2) !== def.lang.slice(0, 2));
if (same.length) warn('check', `what's new of ${same.map(x => x.lang).join(', ')} is the same text as ${def!.lang}: translate it`);
if (same.length) note(`what's new of ${same.map(x => x.lang).join(', ')} is the same text as ${def!.lang}: translate it`);
return `${copy.length} languages`;
});
if (config.apple) tryDo('appstore listing', () => {
const f = resolve(config.apple!.listing ?? 'store/appstore.md');
const copy = parseAppStoreListing(readFileSync(f, 'utf8'));
const missing = config.languages.filter(l => l.apple && !copy[l.apple]).map(l => l.apple);
if (missing.length) warn('check', `appstore listing has no section for ${missing.join(', ')}`);
if (missing.length) note(`appstore listing has no section for ${missing.join(', ')}`);
return `${Object.keys(copy).length} locales`;
});
if (config.dataSafety) tryDo('data safety', () => `${dataSafetyRows(config.dataSafety!).length - 1} CSV rows`);
@ -74,6 +81,7 @@ export async function run(ctx: Ctx): Promise<void> {
if (existsSync(resolve('.gitignore')) && !/^\/?\.storebound\/?$/m.test(readFileSync(resolve('.gitignore'), 'utf8')))
problems.push('.gitignore does not ignore .storebound/ (credentials live there)');
if (ctx.args.has('json')) { printJson({ config: path, ok: !problems.length, items, warnings, problems }); if (problems.length) process.exitCode = 1; return; }
if (problems.length) { for (const p of problems) console.error(` - ${p}`); throw new Error(`${problems.length} problems`); }
log('check', 'all good');
}