@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.
Files changed (2) hide show
  1. package/index.ts +9 -2
  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 it may modify state.\nCommand: ${event.input.command}` };
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bacnh85/pi-plan",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Pi extension that adds a plan mode with workspace markdown plans and thinking-level presets.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {