Skip to content

Commit 44b6321

Browse files
author
luigi liu
committed
Leave empty Kiro agent files untouched
1 parent 5a578c2 commit 44b6321

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎awscli/customizations/agenttoolkit/hooks.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff 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

‎tests/unit/customizations/agenttoolkit/test_hooks.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
709717
def test_kiro_agent_hook_added_to_default_agent(tmp_path):
710718
spawn = {'command': 'git status'}
711719
other = {'matcher': 'fs_write', 'command': 'lint'}

0 commit comments

Comments
 (0)