Open
Conversation
Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Implements hook integration following the existing integrator pattern:
- HookIntegrator discovers hooks in .apm/hooks/ and hooks/ directories
- VSCode: copies hook JSON to .github/hooks/ with script path rewriting
- Claude: merges hooks into .claude/settings.json with script copying
- Sync/cleanup for uninstall (nuke-and-regenerate pattern)
- Script path rewriting for ${CLAUDE_PLUGIN_ROOT} and relative paths
- Gitignore updates for APM-managed hook files
- CLI integration in both install blocks (cached + fresh) and uninstall
- 42 comprehensive tests including official plugin format coverage
Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
…rations docs Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
…omment Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for hooks as an agent primitive
feat: Support Hooks as an Agent Primitive
Feb 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds Hooks as a first-class APM primitive, enabling lifecycle event handlers (PreToolUse, PostToolUse, Stop, etc.) to be packaged and distributed via APM. This is APM's first non-markdown, composite primitive where hook JSON files reference scripts that must travel together.
Changes:
- Adds
HookIntegratorfor discovering, integrating, and managing hook files with target-aware placement (VSCode vs Claude) - Implements dual-path integration: VSCode uses file-based
.github/hooks/*.json, Claude merges into.claude/settings.jsonwith_apm_sourcetracking - Updates install/uninstall flows to handle hooks alongside existing primitives
- Includes comprehensive test suite (42 tests) covering real-world plugin structures from
anthropics/claude-plugins-official
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/apm_cli/integration/hook_integrator.py |
Core hook integration logic with discovery, VSCode/Claude integration, path rewriting, sync/cleanup, and gitignore updates |
src/apm_cli/integration/__init__.py |
Exports HookIntegrator for use in CLI |
src/apm_cli/cli.py |
Integrates hooks into install/uninstall flows with target-aware handling for both cached and freshly downloaded packages |
src/apm_cli/models/apm_package.py |
Adds 'hooks' to primitive types in has_primitives() check |
src/apm_cli/deps/package_validator.py |
Adds hook validation and counting in package structure validation |
tests/unit/integration/test_hook_integrator.py |
Comprehensive test coverage (42 tests) for hook discovery, integration, path rewriting, and cleanup |
docs/primitives.md |
Documents hooks as a primitive type with directory structure |
docs/integrations.md |
Documents hook integration flow for both VSCode and Claude targets |
uv.lock |
Version bump to 0.7.3 |
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.
🚀 New Feature
Description
Adds Hooks as a first-class APM primitive. Hooks are lifecycle event handlers (
PreToolUse,PostToolUse,Stop, etc.) shared by both VSCode Copilot (.github/hooks/*.json) and Claude Code (.claude/settings.json). This is APM's first non-markdown, composite primitive — hook JSON files reference scripts that must travel together.Target-aware placement:
.apm/hooks/*.jsonorhooks/*.json.github/hooks/<pkg>-<name>-apm.json.claude/settings.jsonhookskey.github/hooks/scripts/<pkg>/.claude/hooks/<pkg>/Script path rewriting handles
${CLAUDE_PLUGIN_ROOT}/path,./relative/path, and system commands (passthrough).Changes Made
HookIntegratorinsrc/apm_cli/integration/hook_integrator.py— discovery, VSCode integration, Claude merge, sync/cleanup, gitignorePackageInfo.has_primitives()andPackageValidatornow recognize.apm/hooks/anthropics/claude-plugins-official(hookify, learning-output-style, ralph-loop)docs/primitives.md— hooks listed as primitive type with directory structuredocs/integrations.md— hook integration flow for VSCode and Claude targetsTesting
Checklist
enhancementorfeaturelabel to this PROriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.