Repository navigation
fix(dev-tooling): match hook commands exactly and read config like servers - #199
Merged
Martin Bens (SpiGAndromeda) merged 4 commits intoOct 27, 2026
Merged
Conversation
`parse_hook_input` strips heredoc bodies before any detector sees the command, so a line inside a script body such as `vendor/bin/phpunit` no longer reads as a command the hook must block, and an unterminated heredoc removes the rest of the input. The hooks read the MCP config the way the servers do, through `read_mcp_config` (the file named by `MCP_PHP_TOOLING_CONFIG` or `MCP_JS_TOOLING_CONFIG` when set, otherwise every location in the servers' order, deep-merged). A missing override file, or a file that does not hold a JSON object, reads as no config, so enforcement stays on. `lib/js_binary.sh` adds `runs_npm_script` and the shared `COMMAND_POSITION` and `NAME_END` patterns, so a script name matches exactly behind `NAME=value` assignments, npm flags before the script name and `run-script`, and a node_modules binary matches through `node`. The detectors follow the tools. `composer cs` and `cs-fix` replace the deprecated `ecs` alias, `composer rector-fix` is blocked, `npm run unit` replaces `jest:base`, and the Storefront `lint` and `lint-fix` scripts name both linters. The script names the tools no longer use (`stylelint:base`, `prettier:base`, `jest:base`, `eslint:app`, `eslint:components`, `stylelint:app`) are dropped from the detectors. `session-start.sh` decides enforcement per language and leaves out the directive lines and scopes section of an opted-out language. The prompts put each routing statement on its own line and name `js-storefront-tooling` for the ludtwig refusal. Co-Authored-By: Claude <noreply@anthropic.com>
A Vitest run without a Storefront path, such as `npx vitest run` or `npm exec -- vitest run`, passed both JS hooks: the Storefront hook found no Storefront marker, and the Admin hook has no Vitest row. The Storefront hook now treats a Vitest binary run as Storefront context unless the command names `Administration`. Both hooks treat a `views/components` path as Storefront, so the Storefront hook blocks `npm exec --no -c "cd ../.. && eslint views/components"` with `eslint_check` and the Admin hook lets it pass. The PHP hook matches a Composer script after global options, so `composer -d <dir> phpstan` and `composer --working-dir=<dir> run phpunit` are blocked. Co-Authored-By: Claude <noreply@anthropic.com>
`mcp-enforcement.md` drops the script rows the hooks no longer match (`stylelint:base`, `prettier:base`, `jest:base`, `eslint:app`, `eslint:components`, `stylelint:app`) and lists `composer cs`, `cs-fix` and `rector-fix` with the one tool each routes to. It states how each JS hook claims a command, including `views/components` and Vitest runs, that heredoc bodies are not matched, how the hooks read the config, and which forms of Composer and npm script runs match. Co-Authored-By: Claude <noreply@anthropic.com>
Agent Skills ExportBuilt 7 skill packages: |
`parse_hook_input` no longer removes heredoc bodies. The stripping let commands run unblocked: a heredoc piped into `bash`, a delimiter with a `-` or `.` that cut off the rest of the command, a `<<` inside quotes, and an opener line continued with `\`. Every line of a command is matched again. `read_mcp_config` checks each discovered file before the merge, so an empty file, or one that is not a JSON object, makes the hook read no config and keep enforcement on. Before, `jq -s` dropped an empty file and a lower-priority `enforce_mcp_tools: false` decided. The Storefront hook no longer claims every Vitest run without a Storefront marker, because it routed a plugin's own Vitest suite to `vitest_run`, which refuses plugin scopes. `COMPOSER_RUN` in `lib/js_binary.sh` is the one Composer pattern for the PHP and Storefront hooks, so the Storefront hook now matches Composer scripts after global options such as `-d <dir>`. `composer ecs` names only `ecs_check` and `composer ecs-fix` only `ecs_fix`. `session-start.sh` reports a config's scopes even when its language sets `enforce_mcp_tools: false`. Co-Authored-By: Claude <noreply@anthropic.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.
The PreToolUse hooks now read the MCP config the way the servers do, and match command names exactly in the forms the tools actually run. Commands that ran a tool through
node, throughcomposer runor behind aNAME=valueprefix are now blocked, and a longer script name is no longer read as a shorter one. No tool or parameter was removed.This PR carries no version bump.
MCP_PHP_TOOLING_CONFIGorMCP_JS_TOOLING_CONFIG, else every location deep-merged..claude/.mcp-*.jsonor.mcp-*.json, whichever they found first.NAME=valueprefixes, throughnpm run-script, and past npm flags that take no value or--prefix <dir>beforerun.node node_modules/.bin/<tool>is matched.composer cs,composer cs-fixandcomposer rector-fix.composer csandcomposer ecsname onlyecs_check,composer cs-fixandcomposer ecs-fixonlyecs_fix, andcomposer rector-fixonlyrector_fix.runorrun-scriptand after global options such as-d <dir>or--working-dir=<dir>.views/componentspath marks a command as Storefront in both JS hooks.npm exec --no -c "cd ../.. && eslint views/components"is now blocked by the Storefront hook witheslint_checkinstead of by the Administration hook.npm run lintandnpm run lint-fixblocks name both the ESLint and the Stylelint tools.stylelint:base,prettier:base,jest:base,eslint:app,eslint:componentsandstylelint:appare removed.lint:js:app,lint:js:components, their:fixvariants andlint:fixare removed.package.jsonfiles define none of the six names dropped from the shared rows, and the Storefront package defines none of its removedlint:js:*orlint:fixrows.session-start.shdecides enforcement per language and leaves out the directive lines of a language that setsenforce_mcp_tools: false. The scopes section of that language stays.Docs:
plugins/dev-tooling/docs/mcp-enforcement.mddocuments the config reading, JS context detection and the matched command forms.