desktop: Fix with AI on scan findings that need a code change (aiFix: true, AI_FIX_RULES). The host (src-tauri/src/ai_fix.rs) runs the owner's local Claude Code headless in the app folder with Read / Edit / Write / Grep / Glob only (Bash, web tools, sub-agents disallowed) and a prompt it builds from the finding's fields; it refuses while the folder has uncommitted files, streams progress, times out after 10 min with a heartbeat, kills the process group on Cancel or exit, and records the run's changed files so Undo restores exactly those; the window shows the diff with Keep / Undo and rescans. Without claude the button copies the prompt (Copy for AI). Only the claude binary, git and kill / taskkill are started there (tests/security.rs); tests/ai_fix.rs covers the prompt, dirty-tree refusal, undo scope, timeout and cancel

This commit is contained in:
CRTkafa 2026-10-15 06:26:29 +08:00
parent 992f5bcc0e
commit c95f2af8ff
24 changed files with 1023 additions and 10 deletions

View file

@ -72,6 +72,15 @@ Types of the protocol: `cli/lib/desktop-protocol.ts`; pure portfolio logic: `cli
config, the dialog shows the config diff), Play listing gaps -> `play.listing`, App Store missing localization and
copyright -> `apple.listing` (editable version only), App Review contact -> `apple.review_details`. No fix reaches
a submit, release or publish (tests/fix-actions.test.ts).
Findings whose fix is a code or project-file change (`aiFix: true`, AI_FIX_RULES: ATS, foreground service types,
purpose strings, target SDK, ...) get **Fix with AI**: the host (src-tauri/src/ai_fix.rs) runs the owner's local
Claude Code (`claude -p`, found on PATH or its usual install folders) in the app folder with only Read, Edit, Write,
Grep and Glob (Bash, web tools and sub-agents disallowed), a prompt it builds from the finding's fields (the window
cannot send free text), a 10 minute timeout with a heartbeat, and kill by PID (process group) on Cancel or app exit.
It refuses while the app folder has uncommitted files (and lists them), so the diff afterwards is the run's own work;
the window shows it with Keep and Undo (the host restores exactly the files that run changed and removes the ones it
created) and rescans to say whether the finding is gone. Without claude the button is **Copy for AI** (the same
prompt). The host only starts the claude binary, git and kill / taskkill there (tests/security.rs, tests/ai_fix.rs).
- **First-run guide**: what the app does, add or start an app folder (`project.init` = `storebound init --profile`,
confirmed in a native dialog), store keys into the shared credential profiles and which app uses which, local
tools, first read.