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

@ -13,7 +13,7 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import { ascClient, type Asc, type J } from './apple/asc';
import type { Ctx } from './lib/ctx';
import { confirm, need } from './lib/ctx';
import { done, log, step, warn } from './lib/log';
import { done, log, printJson, step, warn } from './lib/log';
import { toMoney } from './lib/money';
import {
appleSchedule, appleScheduleBody, applePriceRows, diffPrices, diffTable, parsePriceCsv, type PlayProduct, playPatchBody, playPriceRows, playRegions,
@ -96,10 +96,12 @@ export async function run(ctx: Ctx): Promise<void> {
const wantedAll = parsePriceCsv(readFileSync(csvPath, 'utf8'), { products: config.products!.map(p => p.id) })
.filter(r => products.some(p => p.id === r.product) && ((r.store === 'apple' && useApple) || (r.store === 'play' && usePlay)));
const diff = diffPrices(current, wantedAll);
console.log(diffTable(diff, { all: a.has('all') }));
const changed = new Set(diff.filter(d => d.change !== 'same').map(d => `${d.product}|${d.store}`));
const reconvert = a.has('reconvert');
if (reconvert && usePlay) for (const p of products) if (playProducts.has(p.id)) changed.add(`${p.id}|play`);
// --json is a read-only diff: it never writes, whatever the other flags say.
if (a.has('json')) { printJson({ csv: csvPath, diff: a.has('all') ? diff : diff.filter(d => d.change !== 'same'), changed: [...changed] }); return; }
console.log(diffTable(diff, { all: a.has('all') }));
if (!changed.size) { done(TAG, 'prices up to date'); return; }
log(TAG, `${changed.size} product / store pair(s) to update`);
if (dry) { done(TAG, 'dry run: nothing written'); return; }