@bacnh85/pi-plan 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +9 -2
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -152,6 +152,13 @@ function isDestructiveBash(command: string): boolean {
|
|
|
152
152
|
return DESTRUCTIVE_BASH_PATTERNS.some((pattern) => pattern.test(command));
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
function isReadOnlyBash(command: string): boolean {
|
|
156
|
+
const trimmed = command.trim();
|
|
157
|
+
if (!trimmed) return true;
|
|
158
|
+
if (/[;&|`$(){}]/.test(trimmed) || /\b(python|python3|node|ruby|perl|php|sh|bash|zsh|fish)\b/i.test(trimmed)) return false;
|
|
159
|
+
return /^(git\s+(status|branch|rev-parse|diff|show|log|ls-files)\b|(?:rg|grep|find|fd|ls|pwd|cat|head|tail|sed|awk|wc|sort|uniq|cut)\b)/i.test(trimmed);
|
|
160
|
+
}
|
|
161
|
+
|
|
155
162
|
export default function piPlanExtension(pi: ExtensionAPI): void {
|
|
156
163
|
let planModeEnabled = false;
|
|
157
164
|
let executionMode = false;
|
|
@@ -488,8 +495,8 @@ export default function piPlanExtension(pi: ExtensionAPI): void {
|
|
|
488
495
|
return { block: true, reason: `pi-plan: ${event.toolName} is disabled in read-only plan mode. Use ${PLAN_TOOL} to write the plan file.` };
|
|
489
496
|
}
|
|
490
497
|
if (!isToolCallEventType("bash", event)) return;
|
|
491
|
-
if (isDestructiveBash(event.input.command)) {
|
|
492
|
-
return { block: true, reason: `pi-plan: bash command blocked in plan mode because
|
|
498
|
+
if (isDestructiveBash(event.input.command) || !isReadOnlyBash(event.input.command)) {
|
|
499
|
+
return { block: true, reason: `pi-plan: bash command blocked in plan mode because only simple read-only inspection commands are allowed.\nCommand: ${event.input.command}` };
|
|
493
500
|
}
|
|
494
501
|
});
|
|
495
502
|
|