-
Notifications
You must be signed in to change notification settings - Fork 67
Bug: Hook integrator does not process 'windows' property – scripts not copied and paths not rewritten #520
Description
Bug Description
When a hook file (.apm/hooks/*.json) contains a windows property alongside command, bash, or powershell, the windows property is not processed during compilation/installation. This means:
- Script files referenced in the
windowsproperty are not copied to.github/hooks/scripts/ - Paths in the
windowsproperty are not rewritten to the installed location (e.g..github/hooks/scripts/dotnet/secrets-scanner/scan-secrets.ps1)
Only the command, bash, and powershell properties work correctly.
Root Cause Analysis
File: src/apm_cli/integration/hook_integrator.py — lines 234 and 248
The hook path-rewriting code iterates over a hardcoded tuple of keys that does not include "windows":
# Line 234 – GitHub Copilot flat format (matcher-level)
for key in ("command", "bash", "powershell"):
if key in matcher:
new_cmd, scripts = self._rewrite_command_for_target(
matcher[key], package_path, package_name, target,
hook_file_dir=hook_file_dir,
)
matcher[key] = new_cmd
all_scripts.extend(scripts)
# Line 248 – Claude nested format (hooks array)
for key in ("command", "bash", "powershell"):
if key in hook:
new_cmd, scripts = self._rewrite_command_for_target(
hook[key], package_path, package_name, target,
hook_file_dir=hook_file_dir,
)
hook[key] = new_cmd
all_scripts.extend(scripts)Because "windows" is missing from the tuple in both locations, the _rewrite_command_for_target() function is never called for that key, so scripts are not copied and paths are not rewritten.
History
Commit 39e4c4d previously fixed this same class of bug by adding bash and powershell to the tuple (previously only command was handled). The windows key was overlooked in that fix.
Suggested Fix
Add "windows" to the key tuple in both locations (lines 234 and 248):
for key in ("command", "bash", "powershell", "windows"):Or more robustly, consider dynamically processing all keys that may contain script path references to prevent similar omissions in the future.
Steps to Reproduce
- Create a package with a hook in
.apm/hooks/that has awindowsproperty pointing to a script - Run
apm installorapm compile - Observe that files from
commandare copied to.github/hooks/but files fromwindowsare not - Observe that
windowspaths remain as original relative paths instead of being rewritten