You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR #148 committed example dart_hooks.yaml files whose keys don't match the keys the code actually looks for. A user who copies one of these files (or treats it as the reference)
ends up with hooks that silently stay disabled, with no obvious error.
Details
The example files added in #148 use the script filenames as keys:
But BaseHook.run() in tool/dart_hooks/lib/src/base_hook.dart gates on each hook's configKey, which is the class name:
tool/dart_hooks/lib/src/dart_format_hook.dart → String get configKey => 'DartFormatHook';
tool/dart_hooks/lib/src/dart_analyze_hook.dart → String get configKey => 'DartAnalyzeHook';
Since agent_dart_format.dart / agent_dart_analyze.dart are not DartFormatHook / DartAnalyzeHook, yaml.containsKey(configKey) is false and the hook exits via the "key is missing"
branch. The README.md (also updated in #148) documents the correct keys, so the README and the committed example files contradict each other.
Expected
The example dart_hooks.yaml files enable the hooks, matching the README.
Actual
With the committed example files, both hooks are skipped. The log shows:
Hook dart format is disabled (key "DartFormatHook" is missing in configuration).
Hook dart analyze is disabled (key "DartAnalyzeHook" is missing in configuration).
and the hook prints {"decision":"stop"} and exits 0.
Run agent_dart_format/agent_dart_analyze with --log from the .agents directory.
Inspect .agents/dart_format.log / .agents/dart_analyze.log → "disabled (key ... is missing)" instead of "enabled in configuration."
Suggested fix
Update the three committed dart_hooks.yaml files to use the class-name keys that the code reads (and that the README already documents):
DartFormatHook: true
DartAnalyzeHook: true
Optionally, consider also accepting the script-filename keys as aliases, or validating/warning on unrecognized keys so a typo'd/legacy key doesn't silently disable a hook.
Summary
PR #148 committed example dart_hooks.yaml files whose keys don't match the keys the code actually looks for. A user who copies one of these files (or treats it as the reference)
ends up with hooks that silently stay disabled, with no obvious error.
Details
The example files added in #148 use the script filenames as keys:
dart_hooks.yaml, tool/dart_hooks.yaml, tool/dart_hooks/dart_hooks.yaml
agent_dart_format.dart: true
agent_dart_analyze.dart: true
But BaseHook.run() in tool/dart_hooks/lib/src/base_hook.dart gates on each hook's configKey, which is the class name:
Since agent_dart_format.dart / agent_dart_analyze.dart are not DartFormatHook / DartAnalyzeHook, yaml.containsKey(configKey) is false and the hook exits via the "key is missing"
branch. The README.md (also updated in #148) documents the correct keys, so the README and the committed example files contradict each other.
Expected
The example dart_hooks.yaml files enable the hooks, matching the README.
Actual
With the committed example files, both hooks are skipped. The log shows:
Hook dart format is disabled (key "DartFormatHook" is missing in configuration).
Hook dart analyze is disabled (key "DartAnalyzeHook" is missing in configuration).
and the hook prints {"decision":"stop"} and exits 0.
Repro
Suggested fix
Update the three committed dart_hooks.yaml files to use the class-name keys that the code reads (and that the README already documents):
DartFormatHook: true
DartAnalyzeHook: true
Optionally, consider also accepting the script-filename keys as aliases, or validating/warning on unrecognized keys so a typo'd/legacy key doesn't silently disable a hook.
Environment