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
windows property are not copied to .github/hooks/scripts/
- Paths in the
windows property 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 a windows property pointing to a script
- Run
apm install or apm compile
- Observe that files from
command are copied to .github/hooks/ but files from windows are not
- Observe that
windows paths remain as original relative paths instead of being rewritten
Bug Description
When a hook file (
.apm/hooks/*.json) contains awindowsproperty alongsidecommand,bash, orpowershell, thewindowsproperty is not processed during compilation/installation. This means:windowsproperty are not copied to.github/hooks/scripts/windowsproperty are not rewritten to the installed location (e.g..github/hooks/scripts/dotnet/secrets-scanner/scan-secrets.ps1)Only the
command,bash, andpowershellproperties work correctly.Root Cause Analysis
File:
src/apm_cli/integration/hook_integrator.py— lines 234 and 248The hook path-rewriting code iterates over a hardcoded tuple of keys that does not include
"windows":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
39e4c4dpreviously fixed this same class of bug by addingbashandpowershellto the tuple (previously onlycommandwas handled). Thewindowskey was overlooked in that fix.Suggested Fix
Add
"windows"to the key tuple in both locations (lines 234 and 248):Or more robustly, consider dynamically processing all keys that may contain script path references to prevent similar omissions in the future.
Steps to Reproduce
.apm/hooks/that has awindowsproperty pointing to a scriptapm installorapm compilecommandare copied to.github/hooks/but files fromwindowsare notwindowspaths remain as original relative paths instead of being rewritten