peon is done

This commit is contained in:
2026-03-10 15:49:04 +00:00
parent 68a7753500
commit c76a74ca6f
41 changed files with 916 additions and 8 deletions
+3 -2
View File
@@ -6,7 +6,6 @@
*/
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
import { sendNotification } from "./notify.js";
export default function (pi: ExtensionAPI) {
const dangerousPatterns = [/\brm\s+(-rf?|--recursive)/i, /\bsudo\b/i, /\b(chmod|chown)\b.*777/i];
@@ -18,12 +17,14 @@ export default function (pi: ExtensionAPI) {
const isDangerous = dangerousPatterns.some((p) => p.test(command));
if (isDangerous) {
// Emit event for sound extensions (play sound regardless of UI mode)
pi.events.emit("peon:input_required", { source: "permission-gate", action: "dangerous-command", command });
if (!ctx.hasUI) {
// In non-interactive mode, block by default
return { block: true, reason: "Dangerous command blocked (no UI for confirmation)" };
}
sendNotification("Destructive command pending");
const choice = await ctx.ui.select(`⚠️ Dangerous command:\n\n ${command}\n\nAllow?`, ["Yes", "No"]);
if (choice !== "Yes") {