desktop: a Fix button on scan and validate findings storebound can fix itself. Findings carry action { method, args } (cli/lib/fix-actions.ts); privacy-labels runs scan.write (scan --write-only, the dialog shows the config diff), Play listing gaps play.listing, a missing App Store localization or copyright apple.listing (editable version only), the App Review contact apple.review_details; each a dry run, the native dialog, then the confirmed run. --write-only is forbidden for MCP tools; tests pin the mapping, the round trip on a fixture and that no fix reaches a submit, release or publish

This commit is contained in:
CRTkafa 2026-10-15 06:14:49 +08:00
parent bd83d036ba
commit 992f5bcc0e
18 changed files with 257 additions and 37 deletions

23
cli/lib/fix-actions.ts Normal file
View file

@ -0,0 +1,23 @@
// Machine-readable fixes of scan and validate findings: the desktop's "Fix" button runs `action.method` with
// `action.args` as a write (dry run, the native dialog showing it, then the real run with a host-minted token), so the
// window never parses a finding's text. Only fixes an existing command fully determines get an action; the rest has
// none. FIX_METHODS is the whole list: local config writes and store text pushes, never a submit, release or publish
// (tests/fix-actions.test.ts).
export interface FixAction { method: FixMethod; args: Record<string, string> }
export const FIX_METHODS = ['scan.write', 'play.listing', 'apple.listing', 'apple.review_details'] as const;
export type FixMethod = typeof FIX_METHODS[number];
/** Scan rules `storebound scan --write` fixes: the detected Data safety / App Privacy answers go into the config. */
export const SCAN_WRITE_RULES = new Set(['privacy-labels']);
/** The fix of one scan finding: `scan --write` while it would change the config (detected answers only). */
export function scanFixAction(rule: string, o: { configPath: string | null; declarationsChanged: boolean }): FixAction | undefined {
return SCAN_WRITE_RULES.has(rule) && o.configPath && o.declarationsChanged ? { method: 'scan.write', args: {} } : undefined;
}
/** Validate findings fixed by pushing the listing files / config to the store (text only, never submitted). */
export const fixPlayListing = (): FixAction => ({ method: 'play.listing', args: {} });
export const fixAppleListing = (version: string): FixAction => ({ method: 'apple.listing', args: { version } });
export const fixReviewDetails = (): FixAction => ({ method: 'apple.review_details', args: {} });