Repository navigation
Conversation
Blast Radius only watched the Bash tool, so on Windows, where shell commands run through the PowerShell tool, risky commands were never held. - Register a second tool.call hook for PowerShell, sharing the hold, pane and decision logic with Bash through guard(). - Add a PowerShell classifier: Remove-Item and its aliases with -Recurse/-Force (abbreviated parameter names allowed), plus Set-Location, Push-Location and Pop-Location for folder tracking. - Share git and migration detection between both shells. - Measure Remove-Item through pwsh, falling back to powershell, with paths passed as arguments so nothing in them runs as script. - Add tests: classifier coverage for both shells, and hold-queue tests for Cancel, Proceed and overlapping calls. - Update the README for PowerShell support and its limits.
jmseguin
requested review from
ThariqS,
addy-ant,
cj-ant and
rlancemartin
as code owners
October 10, 2026 18:20
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
pwsh -Command does not fill $args from trailing arguments; it joins them onto the script text. The measuring and folder-resolving scripts therefore failed to parse and reported "delete nothing" for real paths, and a path containing a space or a semicolon would have been read as script. Send the values as percent-encoded JSON instead. encodeURIComponent plus an escaped quote leaves nothing in a path that can end the string literal. The scripts read them from $inputs. Add a test that records what the mod sends and checks a hostile path arrives only in encoded form. The earlier tests stubbed process.run and could not see this.
…"nothing to delete" When the measuring script failed it printed nothing, and the empty output was read as "no file matches". The pane then told the user a command that deletes files had nothing to delete. Check the exit code and empty output, and say the paths could not be measured, with the first line of stderr. Also split output on \r\n, so Windows line endings do not leave stray carriage returns in the pane, and add a test for the failure path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Blast Radius only watched the
Bashtool. On Windows, where Claude Code runs shell commands through thePowerShelltool, risky commands were never held. This adds PowerShell support and the first tests for the mod.tool.callhook forPowerShell. Both shells share one hold, pane and decision path (guard()), so one hold at a time still applies across them.Remove-Itemand its default aliases (ri,rd,erase,del,rmdir) with-Recurseor-Force, including abbreviated parameter names, plusSet-Location,Push-LocationandPop-Locationfor folder tracking.Remove-Itemthroughpwsh, falling back topowershell.Directory
claude-code/mods/blast-radius/How paths reach PowerShell
pwsh -Command <script> <arg>does not fill$args. It joins trailing arguments onto the script text, so the first version of the measuring scripts failed to parse, and a path containing a space or;would have been read as script. The mod now sends paths as percent-encoded JSON:encodeURIComponentplus an escaped quote leaves nothing in a path that can end the string literal or run. The scripts read the values from$inputs. This is the same "paths are data, never script" property the Bash path has.Tests
The mod had no tests. This adds two files, run with
claude plugin test:tests/classify.test.ts: classifier coverage for both shells, including the documented gaps. These cases also pin down the existing Bash behavior the refactor touches.tests/guard.test.ts: the hold queue (Cancel refuses, Proceed runs, a second risky call waits for the first), plus a test that records what the mod sends to PowerShell and checks that a hostile path arrives only encoded. Time is driven by the test kit's mock clock, because the hold loop polls until a button is pressed.Verification
claude plugin validate: passes.claude plugin test: 31 tests, 31 pass.pwshand Windows PowerShell 5.1, against a throwaway folder. This covered a plain folder, a glob, a missing path, a hidden file, and a folder namedit's $(calc) dir. File counts and sizes were correct, and nothing in a path executed. The unit tests stubprocess.run, so they cannot catch a script that fails to parse; this manual run is what found the$argsproblem./reload-plugins: a PowerShellRemove-Item -Recurse -Forceon a 31-file folder (130,843 bytes) opened the pane showing "delete 31 files (about 128 KB)" with real paths and "+ 21 more", and the command ran after Proceed was pressed. A failed measurement now reads "could not measure it" with the PowerShell error, instead of "nothing to delete". This was a manual check, not covered by a test.Known limits (also in the README)
Get-ChildItem | Remove-Item -Force) is not caught.$(...), script blocks, splatting, here-strings,Invoke-Expressionand user-defined aliases are not read.-WhatIfand-Confirm:$falseare not special-cased.cmd.execommands such asrd /s /qdo not go through the PowerShell tool and are not held.Pre-flight
Full checklist:
_template/PREFLIGHT.mdThis is an outside contribution to an existing entry, not a new one, so the new-entry items (name, Dependencies table, Third-party notices) are unchanged. The items I checked:
CONTRIBUTING.mdsays outside pull requests may be closed without review, so this is offered as-is.