File tree Expand file tree Collapse file tree
awscli/customizations/agenttoolkit
tests/unit/customizations/agenttoolkit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -275,8 +275,9 @@ def install_kiro_agent_hook(agent):
275275 action = _add_entry (data , _KIRO_AGENT_FORMAT , _kiro_agent_handler ())
276276 except _UnreadableError :
277277 return HookAction .UNREADABLE , path
278- if text is None :
279- # Removed since it was found. A new file would not be an agent.
278+ if text is None or not text .strip ():
279+ # Removed since it was found, or empty. Adding only our hook would
280+ # not make it an agent.
280281 return HookAction .NOT_SUPPORTED , None
281282 if action is not HookAction .INSTALLED :
282283 return action , path
Original file line number Diff line number Diff line change @@ -706,6 +706,14 @@ def test_kiro_missing_default_agent_file_is_not_supported(tmp_path):
706706 assert os .listdir (tmp_path / '.kiro' / 'agents' ) == ['other.json' ]
707707
708708
709+ @pytest .mark .parametrize ('content' , ['' , ' \n ' ])
710+ def test_kiro_empty_default_agent_file_is_not_supported (tmp_path , content ):
711+ agent = _kiro_with_agents (tmp_path , {'my-agent.json' : content })
712+ path = tmp_path / '.kiro' / 'agents' / 'my-agent.json'
713+ assert install_kiro_agent_hook (agent ) == (HookAction .NOT_SUPPORTED , None )
714+ assert path .read_text () == content
715+
716+
709717def test_kiro_agent_hook_added_to_default_agent (tmp_path ):
710718 spawn = {'command' : 'git status' }
711719 other = {'matcher' : 'fs_write' , 'command' : 'lint' }
You can’t perform that action at this time.
0 commit comments