fix: process windows hook key for script copying and path rewriting#521
Merged
danielmeppiel merged 8 commits intomainfrom Apr 2, 2026
Merged
fix: process windows hook key for script copying and path rewriting#521danielmeppiel merged 8 commits intomainfrom
windows hook key for script copying and path rewriting#521danielmeppiel merged 8 commits intomainfrom
Conversation
Agent-Logs-Url: https://github.com/microsoft/apm/sessions/8ea8e0b4-eccd-436e-92c2-fefdbd55ba3c Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
… hook transcription Add class-level HOOK_COMMAND_KEYS tuple as single source of truth for hook command keys that contain script-path references. This replaces the two hardcoded tuples in _rewrite_hooks_data() and includes the previously missing "windows" key. Also adds Python logging (debug level) for hook transcription so verbose output reports which keys were rewritten and how many scripts were extracted per key. Fixes #311 Agent-Logs-Url: https://github.com/microsoft/apm/sessions/8ea8e0b4-eccd-436e-92c2-fefdbd55ba3c Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
… add changelog entry Agent-Logs-Url: https://github.com/microsoft/apm/sessions/8ea8e0b4-eccd-436e-92c2-fefdbd55ba3c Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix bug: Process 'windows' property in hook integrator
fix: process Mar 31, 2026
windows hook key for script copying and path rewriting
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes hook script copying/path rewriting for the windows hook key by centralizing the set of hook command keys and extending rewrite logic to include windows, with accompanying unit tests and a changelog entry.
Changes:
- Introduce
HookIntegrator.HOOK_COMMAND_KEYSand iterate over it in_rewrite_hooks_data()sowindowsis processed consistently. - Add debug logging when hook keys are rewritten and scripts are extracted.
- Add unit tests covering
windowsin both flat and nested hook formats, plus updateCHANGELOG.md.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/apm_cli/integration/hook_integrator.py |
Adds HOOK_COMMAND_KEYS (including windows) and uses it in both rewrite loops; adds debug logging. |
tests/unit/integration/test_hook_integrator.py |
Adds coverage for windows hook rewriting in multiple formats and combined-key scenarios. |
CHANGELOG.md |
Documents the bug fix under ## [Unreleased]. |
Comments suppressed due to low confidence (1)
src/apm_cli/integration/hook_integrator.py:274
- Same as above: extending all_scripts without de-duplication can return duplicate script copy entries, which leads to redundant copies and potential false collision warnings/skips during install. Consider de-duplicating by target_rel before returning.
all_scripts.extend(scripts)
…c coverage The VS Code hooks spec supports `windows`, `linux`, and `osx` as OS-specific command overrides. PR originally only added `windows` — this commit completes coverage by adding `linux` and `osx` to the HOOK_COMMAND_KEYS tuple. Also adds spec reference documentation on the constant, cross-referencing: - GitHub Copilot Agent: bash, powershell keys - VS Code: command, windows, linux, osx keys - Claude Code: command key + shell field Adds tests for linux and osx: direct key rewriting, flat format, nested format, and updates the all-platform-keys test to cover all 6 keys. Refs: #520 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When multiple hook keys (e.g. command and bash) reference the same script file, _rewrite_hooks_data previously returned duplicate (source, target) entries. This caused redundant shutil.copy2 calls and inflated the scripts_copied count. De-duplicate by target_rel before returning so each script is copied exactly once. Addresses PR review comment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Description
_rewrite_hooks_data()iterated over a hardcoded tuple("command", "bash", "powershell")at two sites — thewindowskey was missing, so scripts referenced in it were never copied and paths were never rewritten.Fix: Extract a single
HOOK_COMMAND_KEYSclass constant onHookIntegratorso both loops share one source of truth. Future platform keys require a one-line change.Also adds
logging.debug()in the rewrite loops so verbose output shows which keys were transcribed and how many scripts were extracted per key.Type of change
Testing
Four new tests:
test_rewrite_windows_key,test_rewrite_hooks_data_windows_flat_format,test_rewrite_hooks_data_windows_nested_format,test_rewrite_hooks_data_all_platform_keys.