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

@ -444,6 +444,25 @@ export const en = {
'checks.fixHint.play.listing': 'Pushes the listing file to Google Play (text only, nothing is published). You see the dry run first.',
'checks.fixHint.apple.listing': 'Pushes the listing file and copyright to the App Store version (text only, nothing is submitted). You see the dry run first.',
'checks.fixHint.apple.review_details': 'Sends the App Review contact and notes from the config (nothing is submitted). You see the dry run first.',
'ai.run': 'Fix with AI',
'ai.runHint': 'Runs Claude Code on this machine in the app folder with file tools only (read and edit; no commands, no network, no git push). You see the diff and can undo it.',
'ai.copy': 'Copy for AI',
'ai.copyHint': 'Claude Code (claude) is not installed: copies a prompt for this finding to paste into your AI agent.',
'ai.starting': 'Starting Claude Code...',
'ai.running': 'Claude Code is fixing this finding (at most 10 minutes).',
'ai.dirty': 'Uncommitted files in the app folder ({count}): commit or stash them first, so Undo can restore exactly what the AI changes.',
'ai.noGit': 'The app folder is not in a git repository: Fix with AI needs git for the diff and Undo.',
'ai.cancelled': 'Cancelled',
'ai.timedOut': 'Stopped after 10 minutes',
'ai.noChanges': 'No files changed',
'ai.changed': 'Changed files: {count}',
'ai.stillThere': 'the scan still reports it',
'ai.gone': 'the scan no longer reports it',
'ai.diff': 'Changes',
'ai.keep': 'Keep',
'ai.undo': 'Undo',
'ai.undone': 'Undone. Restored files: {count}',
'ai.failed': 'Fix with AI failed: {msg}',
'checks.accepted': 'Accepted: {reason}',
'checks.sev.blocker': 'Blocker',
'checks.sev.high': 'High',