From 92acd353acfdc2f9db7d5e8182b2aedca1376778 Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Mon, 25 May 2026 16:36:42 -0500 Subject: [PATCH 1/3] Fix dart_hooks.yaml example keys so hooks are actually enabled (#150) The example dart_hooks.yaml files committed in #148 used the script filenames (agent_dart_format.dart / agent_dart_analyze.dart) as keys. BaseHook.run() gates on each hook's configKey, which is the class name (DartFormatHook / DartAnalyzeHook), so copying these files left both hooks silently disabled, contradicting the README. Update all four committed dart_hooks.yaml files to the class-name keys the code reads and the README documents. Also improve the diagnostic: when the expected key is missing, the log now lists the keys that were found and suggests the correct one, so a typo'd or legacy key no longer disables a hook with an opaque message. --- dart_hooks.yaml | 4 ++-- tool/dart_hooks.yaml | 4 ++-- tool/dart_hooks/dart_hooks.yaml | 4 ++-- tool/dart_hooks/lib/src/base_hook.dart | 4 +++- tool/dart_hooks/test/base_hook_test.dart | 4 ++++ tool/dart_skills_lint/dart_hooks.yaml | 4 ++-- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/dart_hooks.yaml b/dart_hooks.yaml index 534acef..a508505 100644 --- a/dart_hooks.yaml +++ b/dart_hooks.yaml @@ -1,2 +1,2 @@ -agent_dart_format.dart: true -agent_dart_analyze.dart: true +DartFormatHook: true +DartAnalyzeHook: true diff --git a/tool/dart_hooks.yaml b/tool/dart_hooks.yaml index 534acef..a508505 100644 --- a/tool/dart_hooks.yaml +++ b/tool/dart_hooks.yaml @@ -1,2 +1,2 @@ -agent_dart_format.dart: true -agent_dart_analyze.dart: true +DartFormatHook: true +DartAnalyzeHook: true diff --git a/tool/dart_hooks/dart_hooks.yaml b/tool/dart_hooks/dart_hooks.yaml index 534acef..a508505 100644 --- a/tool/dart_hooks/dart_hooks.yaml +++ b/tool/dart_hooks/dart_hooks.yaml @@ -1,2 +1,2 @@ -agent_dart_format.dart: true -agent_dart_analyze.dart: true +DartFormatHook: true +DartAnalyzeHook: true diff --git a/tool/dart_hooks/lib/src/base_hook.dart b/tool/dart_hooks/lib/src/base_hook.dart index 3b35091..dcd7720 100644 --- a/tool/dart_hooks/lib/src/base_hook.dart +++ b/tool/dart_hooks/lib/src/base_hook.dart @@ -63,8 +63,10 @@ abstract class BaseHook { final dynamic yaml = loadYaml(configContent); if (yaml is Map) { if (!yaml.containsKey(configKey)) { + final String foundKeys = yaml.keys.join(', '); await logToFile( - 'Hook $hookName is disabled (key "$configKey" is missing in configuration).', + 'Hook $hookName is disabled (key "$configKey" is missing in configuration). ' + 'Found keys: [$foundKeys]. Did you mean to enable it with "$configKey: true"?', ); printStdout(jsonEncode({'decision': 'stop'})); onExit(0); diff --git a/tool/dart_hooks/test/base_hook_test.dart b/tool/dart_hooks/test/base_hook_test.dart index e57e28d..5167f27 100644 --- a/tool/dart_hooks/test/base_hook_test.dart +++ b/tool/dart_hooks/test/base_hook_test.dart @@ -242,6 +242,10 @@ void main() { loggedMessages.first, contains('is disabled (key "test_hook" is missing in configuration)'), ); + // Verify the warning surfaces the keys that were found so a typo'd or + // legacy key (e.g. a script filename) does not silently disable a hook. + expect(loggedMessages.first, contains('Found keys: [other_hook].')); + expect(loggedMessages.first, contains('"test_hook: true"')); }); test('Disabled setting logs disabled', () async { diff --git a/tool/dart_skills_lint/dart_hooks.yaml b/tool/dart_skills_lint/dart_hooks.yaml index 534acef..a508505 100644 --- a/tool/dart_skills_lint/dart_hooks.yaml +++ b/tool/dart_skills_lint/dart_hooks.yaml @@ -1,2 +1,2 @@ -agent_dart_format.dart: true -agent_dart_analyze.dart: true +DartFormatHook: true +DartAnalyzeHook: true From b4f12f6c1ba9d5bb34c6cc2a8391771f5cb32f23 Mon Sep 17 00:00:00 2001 From: Reid Baker <1063596+reidbaker@users.noreply.github.com> Date: Mon, 25 May 2026 17:39:21 -0400 Subject: [PATCH 2/3] Update tool/dart_hooks/lib/src/base_hook.dart Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- tool/dart_hooks/lib/src/base_hook.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/dart_hooks/lib/src/base_hook.dart b/tool/dart_hooks/lib/src/base_hook.dart index dcd7720..13b1732 100644 --- a/tool/dart_hooks/lib/src/base_hook.dart +++ b/tool/dart_hooks/lib/src/base_hook.dart @@ -63,7 +63,7 @@ abstract class BaseHook { final dynamic yaml = loadYaml(configContent); if (yaml is Map) { if (!yaml.containsKey(configKey)) { - final String foundKeys = yaml.keys.join(', '); + final String foundKeys = (yaml as Map).keys.join(', '); await logToFile( 'Hook $hookName is disabled (key "$configKey" is missing in configuration). ' 'Found keys: [$foundKeys]. Did you mean to enable it with "$configKey: true"?', From 0879e0265d4dd0a75e9587eefd44264adabd2c1f Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Mon, 25 May 2026 16:43:42 -0500 Subject: [PATCH 3/3] Remove redundant cast that failed dart analyze --fatal-infos yaml is already promoted to Map by the enclosing `if (yaml is Map)`, so `(yaml as Map)` is an unnecessary_cast that `dart analyze --fatal-infos` treats as fatal. Drop the cast. --- tool/dart_hooks/lib/src/base_hook.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/dart_hooks/lib/src/base_hook.dart b/tool/dart_hooks/lib/src/base_hook.dart index 13b1732..dcd7720 100644 --- a/tool/dart_hooks/lib/src/base_hook.dart +++ b/tool/dart_hooks/lib/src/base_hook.dart @@ -63,7 +63,7 @@ abstract class BaseHook { final dynamic yaml = loadYaml(configContent); if (yaml is Map) { if (!yaml.containsKey(configKey)) { - final String foundKeys = (yaml as Map).keys.join(', '); + final String foundKeys = yaml.keys.join(', '); await logToFile( 'Hook $hookName is disabled (key "$configKey" is missing in configuration). ' 'Found keys: [$foundKeys]. Did you mean to enable it with "$configKey: true"?',