feat: simplify example server to use exact matching#16
Merged
Conversation
Change example server from regex/startswith patterns to exact string matching for clarity and simplicity. This better demonstrates the minimal complexity of the framework. Changes: - Use command == "terraform apply" instead of regex or startswith - Simplified terraform_rule to only handle apply and plan - Replaced complex uv_bundle_rule with simple pip_rule - Removed python_test_file_post_guidance_rule for simplicity - Updated README to reflect exact matching approach - Added note about advanced parsing options and link to DevLeaps Closes #14 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove the middleware system from the agent-policies framework to simplify the architecture. Middleware added unnecessary complexity for the example server and most use cases. Changes: - Removed bash_split_middleware from example server - Removed MiddlewareFunction type from registry - Removed register_middleware and get_middleware from HookRegistry - Removed register_all_middleware helper - Simplified executor to process handlers directly without middleware pipeline - Updated README to remove middleware mentions - Updated tests to reflect simplified behavior (no command chaining) - Removed outdated tests for terraform fmt and command splitting The framework now focuses on simple policy handlers without intermediate transformation layers. Users needing command parsing can implement it within their policy handlers. Related to #14 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR simplifies the example server from regex-based and command-chaining patterns to exact string matching, while removing the unused middleware feature entirely. The changes make the example code clearer and more appropriate for demonstration purposes.
Changes:
- Replaced regex-based command matching with exact string comparisons (
command == "terraform apply") - Removed the bash command splitting middleware and all middleware infrastructure
- Simplified example policies to only handle exact command matches (terraform apply/plan, pip install)
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/devleaps/policies/example/main.py | Simplified policies to use exact matching; removed middleware, guidance, and bundle rules |
| src/devleaps/policies/server/registry.py | Removed all middleware-related functionality and methods |
| src/devleaps/policies/server/executor.py | Simplified execution pipeline by removing middleware processing |
| tests/test_cursor_policies.py | Removed tests for command chaining, regex patterns, and middleware functionality |
| tests/test_claude_code_policies.py | Removed tests for command chaining and argument parsing |
| README.md | Updated documentation to reflect exact matching approach and added note about production parsing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tijmenstor
approved these changes
Jan 19, 2026
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.
Change example server from regex and startswith patterns to exact string matching for clarity. Remove unused middleware feature entirely.
Changes:
Closes #14