feat(dev): add confirmation prompt to apply command (#96)

Add safety confirmation prompt to `core dev apply` before executing
shell commands. This prevents accidental execution of destructive
commands pasted from untrusted sources or generated by AI agents.

Changes:
- Add --yes/-y flag to skip confirmation prompt
- Show warning and require explicit "y" confirmation before execution
- Allow --dry-run to bypass confirmation (no actual execution)
- Use existing cli.Confirm with Required() for mandatory response

Usage:
  core dev apply --command="rm -rf ."     # Prompts for confirmation
  core dev apply --command="..." --yes    # Skips confirmation
  core dev apply --command="..." --dry-run # No execution, no prompt

Closes #81

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Snider 2026-02-01 16:06:04 +00:00 committed by GitHub
parent 451e84aa76
commit 4f1c6926b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,6 +32,7 @@ var (
applyDryRun bool
applyPush bool
applyContinue bool // Continue on error
applyYes bool // Skip confirmation prompt
)
// AddApplyCommand adds the 'apply' command to dev.
@ -54,6 +55,7 @@ func AddApplyCommand(parent *cli.Command) {
applyCmd.Flags().BoolVar(&applyDryRun, "dry-run", false, i18n.T("cmd.dev.apply.flag.dry_run"))
applyCmd.Flags().BoolVar(&applyPush, "push", false, i18n.T("cmd.dev.apply.flag.push"))
applyCmd.Flags().BoolVar(&applyContinue, "continue", false, i18n.T("cmd.dev.apply.flag.continue"))
applyCmd.Flags().BoolVarP(&applyYes, "yes", "y", false, i18n.T("cmd.dev.apply.flag.yes"))
parent.AddCommand(applyCmd)
}
@ -101,6 +103,18 @@ func runApply() error {
}
cli.Blank()
// Require confirmation unless --yes or --dry-run
if !applyYes && !applyDryRun {
cli.Print("%s\n", warningStyle.Render(i18n.T("cmd.dev.apply.warning")))
cli.Blank()
if !cli.Confirm(i18n.T("cmd.dev.apply.confirm"), cli.Required()) {
cli.Print("%s\n", dimStyle.Render(i18n.T("cmd.dev.apply.cancelled")))
return nil
}
cli.Blank()
}
var succeeded, skipped, failed int
for _, repo := range targetRepos {